I have a table that is storing SQL as one of its elements. I need to be able to run that stored SQL query, but can't figure out how to do it. So far, I'm using the following method:
<cfquery name="qDynamicTag" datasource="#myDSN#">
#PreserveSingleQuotes(arguments.sql)#
</cfquery>
If I dump the value of #PreserveSingleQuotes(arguments.sql)#
before executing the cfquery I see the correct SQL statement. However, when I try to run the above cfquery I get a SQLException with the message:
Syntax error at token 0, line 0 offset 0
An example of one of the SQL statements that I'm trying to run:
select productid from catalog.producttag where tag = 'case' or tag = 'cases'
Any ideas on what I'm doing wrong?