Yep, Jon. you're right. doing it that way does work. I'm glad I'm not the only one mad enough wanting to do it this way... he he...
>> and it is much easier to manage with it all broken out. agreed. thanx Steve, Taco and Jon for help. cheers barry.b -----Original Message----- From: Jon Hart [mailto:[EMAIL PROTECTED] Sent: Monday, 23 June 2003 10:29 AM To: CFAussie Mailing List Subject: [cfaussie] RE: <CFQUERY > SQL as a string command > I think Steve might be on the right track here with the extra single quotes within > <CFQUERY> You should have something like this: <cfset queryString = "lots of stuff to generate an SQL query"> <cfquery> #preserveSingleQuotes( queryString )# </cfquery> That's about as simple as it can be. I personally have where clauses and order by clauses that are externally generated strings, while the select and from and some where stuff is constant. That way you can easily what the jibe of the query is. The reason I do it like that is that I have a whole lot of factory methods that each generates a different set of clauses, and it is much easier to manage with it all broken out. > PS: isn't PreserveSingleQuotes() just replace() tailored for quotes? Cfquery is smart, and knows that single quotes in a query is bad. So when you output text into a query it escapes the single quotes. Its based on the assumption that you are doing something like this: select * from bob where bob.name = '#form.name#' This stops you putting single quotes into form.name and killing the query. If you want to do anything more complicated you need to stop cf from escaping those single quotes. What the exact mechanism is, I don't know, but it could just be setting an internal flag somewhere. Once again we struggle with cf's tag orientated, under designed roots. Jon. --- You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] MX Downunder AsiaPac DevCon - http://mxdu.com/ --- You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] MX Downunder AsiaPac DevCon - http://mxdu.com/
