I'm having problems using User Defined Function calls within <CFQUERY>
if the function returns any single quotes. I've included code and the
resultant debug output. Note that single quotes are improperly escaped
in the SQL.
What's the solution?
Code follows...
Thanks,
Jamie
####### CODE ########
<cfset myString="what's the problem?">
<CFQUERY name="myQuery" datasource="myDSN">
INSERT INTO Table (Message)
VALUES ('#myFunction(myString)#')
</CFQUERY>
<cfscript>
// function that does nothing
function myFunction(str) {
return str;
}
</cfscript>
###### DEBUG OUTPUT #######
SQL = "INSERT INTO Table (Message)
VALUES ('what''''s the problem?')"
^^^^Problem SQL
###### COMMENTS ######
If I remove the function call ("myFunction") within the <CFQUERY>,
note that the SQL works as intended, with the resulting VALUE line as
follows:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists