Is it possible to rebind sql paramters using the result from a cfquery?

Posted by Larry on Stack Overflow See other posts from Stack Overflow or by Larry
Published on 2010-05-03T02:09:49Z Indexed on 2010/05/03 2:18 UTC
Read the original article Hit count: 272

Filed under:
|

When I run the following code:

<cfquery name="someQuery" result="queryResult" datasource="wetakepictures">
  SELECT id 
  FROM events
  WHERE category_id = <cfqueryparam value="1" cfsqltype="cf_sql_integer">
     OR title like <cfqueryparam value="%test%" cfsqltype="cf_sql_varchar">
</cfquery>

<cfoutput>
  #queryResult.sql# <br />
  #ArrayToList(queryResult.sqlparameters)#
</cfoutput>

It outputs:

SELECT id FROM events WHERE category_id = ? OR title like ?
1,%test% 

I need the actual string "SELECT id FROM events WHERE category_id = 1 OR title like '%test%'".

Is there a way to rebind the parameters to the sql?

© Stack Overflow or respective owner

Related posts about sql

Related posts about coldfusion