Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFQUERY UPDATE Problem

Status
Not open for further replies.

OldWilly

Programmer
Mar 1, 2002
66
I have no problem updating my tables. But I do seem to have a problem remembering to put in a 'WHERE' clause. Thus, all my records get updated and then I get very irate phone calls. Is there any way I can get an error msg or a warning msg if my update statement is missing the WHERE clause?
 
Wow, you've been around a while, I think...

I'd write a custom tag to evaluate the query... it would be easy (or a function, but I'm forgetful of their syntax right now... so work with me).

Code:
<cfif not thistag.hasendtag or not len(trim(attributes.qcode))>something's broke</cfif>
<cfif thistag.executionmode is not "start">
  <cfset qcode = thistag.generatedcontent>
  <cfif qcode does not contain "where" or qcode does not contain "join">
    Alert! its still broke.<cfabort>
  </cfif>
  <cfset caller.qcode=qcode>
</cfif>

You might tweak that... But the dirty little tag would be called by...

Code:
<cf_tagname>
  ...query...
</cf_tagname>

And then it is returned as a variable called qcode... so you could say...

Code:
<cf_tagname>
  ...query...
</cf_tagname>

<cfquery....>
  #qcode#
</cfquery>

I was thinking about writing this as a function if I could remember the syntax, but because of the nature of queries being multiple lines... I think its more comfortable as a custom tag.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top