Answered
cfqueryparam behaving really strange
Hi!
I have the following scenario.
CFMX 7.0
MS SQL 2005
Col1 and Col3 are nvarchar and Col 2 is an int
Working sql: (returns all rows matching clause)
SELECT * FROM table WHERE col1 = <cfqueryparam cfsqltype="cf_sql_varchar" value="#var1#"> AND col2 = <cfqueryparam cfsqltype="cf_sql_integer" value="#var2#"> AND col3 = <cfqueryparam cfsqltype="cf_sql_varchar" value="staticvalue">
Also working sql (returns all rows matching clause)
SELECT * FROM table WHERE 1=1 AND col1 = <cfqueryparam cfsqltype="cf_sql_varchar" value="#var1#"> AND col2 = <cfqueryparam cfsqltype="cf_sql_integer" value="#var2#"> AND col3 = 'staticvalue'
Not working sql (returns only one row)
SELECT * FROM table WHERE col1 = <cfqueryparam cfsqltype="cf_sql_varchar" value="#var1#"> AND col2 = <cfqueryparam cfsqltype="cf_sql_integer" value="#var2#"> AND col3 = 'staticvalue'
As you can see, using cfqueryparam with the static value makes query #1 work and adding 1=1 in the where clause makes query #2 work. But I find it very, very strange that query #3 shouldn't work - and whats even more strange is that it somehow at least returns one row...
Has anyone experienced any of this behaviour?
Regards,
Johan
I have the following scenario.
CFMX 7.0
MS SQL 2005
Col1 and Col3 are nvarchar and Col 2 is an int
Working sql: (returns all rows matching clause)
SELECT * FROM table WHERE col1 = <cfqueryparam cfsqltype="cf_sql_varchar" value="#var1#"> AND col2 = <cfqueryparam cfsqltype="cf_sql_integer" value="#var2#"> AND col3 = <cfqueryparam cfsqltype="cf_sql_varchar" value="staticvalue">
Also working sql (returns all rows matching clause)
SELECT * FROM table WHERE 1=1 AND col1 = <cfqueryparam cfsqltype="cf_sql_varchar" value="#var1#"> AND col2 = <cfqueryparam cfsqltype="cf_sql_integer" value="#var2#"> AND col3 = 'staticvalue'
Not working sql (returns only one row)
SELECT * FROM table WHERE col1 = <cfqueryparam cfsqltype="cf_sql_varchar" value="#var1#"> AND col2 = <cfqueryparam cfsqltype="cf_sql_integer" value="#var2#"> AND col3 = 'staticvalue'
As you can see, using cfqueryparam with the static value makes query #1 work and adding 1=1 in the where clause makes query #2 work. But I find it very, very strange that query #3 shouldn't work - and whats even more strange is that it somehow at least returns one row...
Has anyone experienced any of this behaviour?
Regards,
Johan
