Skip to main content
Participant
January 6, 2010
Answered

Query Of Queries runtime error

  • January 6, 2010
  • 1 reply
  • 2596 views

Hi,

I am in the process of upgrading my site from CF5 to CF9 and I am receiving a "Query Of Queries runtime error" on the following code whenever I add the first item to my shopping cart. If I add a second item, the error goes away. Here are the two key pieces of code where I pull the item information from the database and then use Query Of Queries to merge the product query with the shopping cart quantity.

<!--- Get Product Details --->

<CFQUERY NAME="GetDetails"

DATASOURCE="#request.ds#"

USERNAME="#request.dsuser#"

PASSWORD="#request.dspass#">

SELECT
ItemNo,

Item,

Grades,

Price,

ImageSmall

FROM Products
WHERE ItemNo IN (#QuotedValueList(GetCart.ItemNo)#)
</CFQUERY>

<!--- Add "OrderQty" Column --->

<CFQUERY NAME="GetList" DBTYPE="query">

SELECT
GetDetails.ItemNo AS ItemNo,

GetDetails.Item AS Item,

GetDetails.Grades AS Grades,

GetDetails.Price AS Price,

GetDetails.ImageSmall AS ImageSmall,

GetCart.Quantity AS OrderQty

FROM GetDetails, GetCart
WHERE GetDetails.ItemNo = GetCart.ItemNo
</CFQUERY>

This is the error I am receiving. The line number references the Q of Q above.

Query Of Queries runtime error.

Comparison exception while executing =.
Incompatible Type Comparison Exception: Left hand side and right hand side of the comparator operator "=" have incompatible types.
Left hand side expression type = "VARCHAR".
Right hand side expression type = "DATE".

I have tried many things to assign a type "string" to the right side but nothing appears to work.

I would greatly appreciate any help I can get as I have spent countless hours trying to figure this out.

Thanks,
Steve

    This topic has been closed for replies.
    Correct answer Dan_Bracuk

    It sounds like the GetCart Query is generated with coldfusion query functions as opposed to a database query.  It also sounds like the QueryNew function has the fieldnames, but not the datatypes.  This means ColdFusion trys to base the datatype on the first few rows of data.

    Or it could be something else.

    1 reply

    Inspiring
    January 6, 2010

    Generally, there are two ways to do this.  One is to use ColdFusion's cast function.  The other is to use database functions, if available, to returns dates as strings.

    In your case, something is amiss.  The combination of this

    WHERE ItemNo IN (#QuotedValueList(GetCart.ItemNo)#)

    and this

    FROM GetDetails, GetCart
    WHERE GetDetails.ItemNo = GetCart.ItemNo

    Makes it hard to figure out how GetCart.ItemNo is perceived to be a date.  If you dump the getcart query right before that q of q, what are some of the values of the ItemNo?

    Participant
    January 6, 2010

    Dan,

    Thanks for the response.

    I too am very confused by this as the code worked perfectly in CF5.

    I am actually using Ben Forta's shopping cart code from his CF5 book.

    I did try what you said earlier and I am confused by what i see.

    1. The items numbers we use can look like 204-004 or 215295 (with or with a dash).

    If I add an item with a dash the error is:

    Left hand side expression type = "VARCHAR".
    Right hand side expression type = "DATE".

    If I add an item without a dash the error is:

    Left hand side expression type = "STRING".
    Right hand side expression type = "LONG".

    2. The other strange thing is that when I add the first item and get the error, if I click to go to the home page, it shows that I have 3 items in my cart, the item I added, as well as the names of two files that I load on the page (menu_var.js and menu9_com.js). These files are used to load my DHTML menu. I use the following code after the Body tag to load the menu.

    <script type="text/javascript">function Go(){return}</script>

    <script type="text/javascript" src="menu_var.js"></script>

    <script type="text/javascript" src="menu9_com.js"></script>

    I can't understand how the file names could find there way into the add to cart tag.

    Any thoughts?

    Dan_BracukCorrect answer
    Inspiring
    January 6, 2010

    It sounds like the GetCart Query is generated with coldfusion query functions as opposed to a database query.  It also sounds like the QueryNew function has the fieldnames, but not the datatypes.  This means ColdFusion trys to base the datatype on the first few rows of data.

    Or it could be something else.