forming a SQL Where string with CFQUERYPARAM- Not working
<cfset strSQLWhere = ''/>
<cfset strSQLWhere = strSQLWhere & " Platform_desc =" & "<cfqueryparam cfsqltype = 'cf_sql_varchar2' value = 'B300/350'/> AND " />
<cfset strSQLWhere = strSQLWhere & " Created_on_dt >= " & "<cfqueryparam cfsqltype = 'cf_sql_date' value = '10/25/2010'/>"/>
<cfquery name='test_Param' datasource = "testDB">
SELECT
Platform_ID,
Platform_desc,
Created_On_Dt
FROm
Test_Table
WHERE
#preserveSinglequotes(strSQLWhere)#
</cfquery>
My Question is the above query is not working. Its always telling me that its missing expresssion or the parameters are not binded. I know that CFQUERYPARAM will work only if it inside the CFQUERY tag, but in my code, they are trying to build this strSQLWHERE string from different pages and connecting it here.
so I cant use the conditional statements inside the cfquery, which would make the query very big and complex. so i m trying to build the where clause and use it in my query.
Though the below query works fine.
<cfquery name='test_Param' datasource = "testDB">
SELECT
Platform_ID,
Platform_desc,
Created_On_Dt
FROm
Test_Table
WHERE
Platform_desc = <cfqueryparam cfsqltype = 'cf_sql_varchar2' value = 'B300/350'/> AND
Created_on_dt >= <cfqueryparam cfsqltype = 'cf_sql_date' value = '10/25/2010'/>
</cfquery>
I m adding CFQUERYPARAM in my queries to improve the performance; Any help would be really appreciated.
Thanks in advance!
