Question
Using a CFQUERYPARAM list IN stmt not working
I have a query I am running against an Oracle 9i db that has
to check a list of codes.
The query listed at the bottom of this post returns expected results using
AND fec.ERROR_CODE IN (# PreserveSingleQuotes(errCodeList)#)
If I try to use
AND fec.ERROR_CODE IN (<CFQUERYPARAM list="yes" value="#errCodeList#"> )
the query returns 0 rows.
OK, here's the "intersting"part. If I change
IN (<CFQUERYPARAM list="yes" value="#errCodeList#"> )
to
NOT IN (<CFQUERYPARAM list="yes" value="#errCodeList#"> )
passing the same exact list the query returns rows!!! I get the opposite results I want, but the query still returns rows. I'm passing the same exact list to the query whether I use PreserveSingleQuotes, CFQUERYPARAM and using both IN and NOT IN constraints.
Why does NOT IN work and IN fail for the same list? Yes, the data is there, I have (at least) triple-checked.
The output from CF debug I get when using CFQUERYPARAM:
SELECT DISTINCT f.field_name,
f.label,
f.field_id,
f.input_type,
f.ERROR_CODE ,
gf.sort_order
FROM group_field gf,
FIELD f,
field_error_code fec
WHERE gf.GROUP_ID = (SELECT GROUP_ID FROM form_group WHERE form_id = ?)
AND gf.field_id = f.field_id
AND f.field_id = fec.FIELD_ID
AND fec.ERROR_CODE IN (?,?,?,?)
ORDER BY gf.sort_order
Query Parameter Value(s) -
Parameter #1(cf_sql_varchar) = FORM_NAME
Parameter #2(cf_sql_varchar) = '130'
Parameter #3(cf_sql_varchar) = '131'
Parameter #4(cf_sql_varchar) = '132'
Parameter #5(cf_sql_varchar) = '133'
It appears a single-quoted, comma-delimted list is being passed to the db for the query.
Any help anyone can give will be greatly appreciated!
The query listed at the bottom of this post returns expected results using
AND fec.ERROR_CODE IN (# PreserveSingleQuotes(errCodeList)#)
If I try to use
AND fec.ERROR_CODE IN (<CFQUERYPARAM list="yes" value="#errCodeList#"> )
the query returns 0 rows.
OK, here's the "intersting"part. If I change
IN (<CFQUERYPARAM list="yes" value="#errCodeList#"> )
to
NOT IN (<CFQUERYPARAM list="yes" value="#errCodeList#"> )
passing the same exact list the query returns rows!!! I get the opposite results I want, but the query still returns rows. I'm passing the same exact list to the query whether I use PreserveSingleQuotes, CFQUERYPARAM and using both IN and NOT IN constraints.
Why does NOT IN work and IN fail for the same list? Yes, the data is there, I have (at least) triple-checked.
The output from CF debug I get when using CFQUERYPARAM:
SELECT DISTINCT f.field_name,
f.label,
f.field_id,
f.input_type,
f.ERROR_CODE ,
gf.sort_order
FROM group_field gf,
FIELD f,
field_error_code fec
WHERE gf.GROUP_ID = (SELECT GROUP_ID FROM form_group WHERE form_id = ?)
AND gf.field_id = f.field_id
AND f.field_id = fec.FIELD_ID
AND fec.ERROR_CODE IN (?,?,?,?)
ORDER BY gf.sort_order
Query Parameter Value(s) -
Parameter #1(cf_sql_varchar) = FORM_NAME
Parameter #2(cf_sql_varchar) = '130'
Parameter #3(cf_sql_varchar) = '131'
Parameter #4(cf_sql_varchar) = '132'
Parameter #5(cf_sql_varchar) = '133'
It appears a single-quoted, comma-delimted list is being passed to the db for the query.
Any help anyone can give will be greatly appreciated!
