On Tue, Apr 26, 2011 at 11:32 AM, Kyle McLean <kmclea...@gmail.com> wrote: > <cfquery name="testQuery" datasource="testDSN"> > SELECT > * > FROM > TBL > <cfif structKeyExists(arguments.testArg)> > WHERE > COL = '#arguments.testArg#' > </cfif> > </cfquery>
I know this doesn't help you, since you're on CF9, but I just wanted to note that Railo also supports an alternative syntax that was discussed by the CFML Advisory Committee - although, unfortunately, we couldn't reach consensus on any proposed syntax (although we were all in agreement that adding CFCs was... less than ideal): query name="testQuery" datasource="testDSN" { writeOutput( "SELECT * FROM TBL" ); if ( structKeyExists(arguments.testArg) ) { writeOutput( "WHERE COL = '#arguments.testArg#'" ); } } Of course, it would be be better to use (cf)queryparam here, like this: query name="testQuery" datasource="testDSN" { writeOutput( "SELECT * FROM TBL" ); if ( structKeyExists(arguments.testArg) ) { writeOutput( "WHERE COL =" ); queryparam value="#arguments.testArg#" cfsqltype="varchar"; } } and I'd write that like this: query name="testQuery" datasource="testDSN" { writeOutput( "SELECT * FROM TBL" ); if ( structKeyExists(arguments.testArg) ) { writeOutput( "WHERE COL =" ); queryparam value="#arguments.testArg#" cfsqltype="varchar"; } } Still a bit ugly with the writeOutput() calls but a lot cleaner than using the CFC, IMO. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Railo Technologies, Inc. -- http://www.getrailo.com/ "Perfection is the enemy of the good." -- Gustave Flaubert, French realist novelist (1821-1880) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:344011 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm