Have you seen this weird QoQ Error [ColdFusion]?

340 views Asked by At

I have confirmed that the first query works as expected

<cfquery name="validation_info" dbtype="query">
    select      shipViaName,TOTALSHIPRATE
    from        s_c_c.qShipCalc
    WHERE       sku in (#preserveSingleQuotes(validate)#)
</cfquery>
<cfquery name="validation_info2" dbtype="query">
    select      TOTALSHIPRATE
    from        validation_info
    WHERE       shipViaName = "FedEx 3 Day"
</cfquery>

But on the second query, I get this error:

Encountered "shipViaName. Incorrect conditional expression, Incorrect conditional expression, Lexical error at line 0, column 0. Encountered: "\"" (34), after : ""

It says the error is happening on this line:

<cfquery name="validation_info2" dbtype="query">

I was also getting this error when I had the two queries combined into one.

Update from comments:

Dump of the validation_info query:

SHIPVIANAME TOTALSHIPRATE

1 | FedEx Ground | 11.9  ||
2 | FedEx 3 Day  | 22.99 || 
3 | FedEx 2 Day  | 26.99 || 
4 | FedEx 1 Day  | 44.55 || 
5 | FedEx Ground | 0     || 
6 | FedEx 3 Day  | 23.63 || 
7 | FedEx 2 Day  | 26.71 || 
8 | FedEx 1 Day  | 41.9  ||
2

There are 2 answers

2
K_Cruz On BEST ANSWER

You need to use single quotes instead of double quotes for your string in your second SQL query.

3
John On

I'd recommend using cfqueryparam for your variables, try this

<cfquery name="validation_info" dbtype="query">
    SELECT      
        shipViaName,
        TOTALSHIPRATE
    FROM        
        s_c_c.qShipCalc
    WHERE       
        sku IN (<cfqueryparam value="#validate#" cfsqltype="CF_SQL_INTEGER" list="yes" /> )
</cfquery>