Query of Query Error

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Query of Query Error

    This is the error I get -
    Query Of Queries syntax error. Encountered ". Query Of Queries runtime error.
    The Cold Fusion server is running MX 7,0,1,116466.
    The sql is "Select * from Invlotquery2 where lotnum = '2011-61-12' ". (The
    extra space after the single quote is for clarity.)
    I have already built the query and the user is trying to filter on a lot
    number. Whenever the lot number starts as numeric and is 10 digits
    long(2011-61-12) the above error happens. A lotnumber thats starts as a
    character or a lot number that starts numeric and has less than 10 characters
    or more than 10 characters works ok. I still have code in place to create a
    dummy record for the query that sets the query fields up as characters. I found
    out that previous versions of Cold Fusion could create query fields as numeric
    if not specified.
    This really seems to be a user specific error but I thought I would post here
    to see if anyone has had a similiar problem or knows of a solution.

    Thanks,

    Dale

    driggle Guest

  2. Similar Questions and Discussions

    1. Query of Queries on query New type query
      In CF5 we have a page that creates a query, using queryNew and querySetCell and the like, we then used dbtype="query" and gave it's name so we could...
    2. Convert a query to a list, or find an item in a query
      Hi All, I am using CFPOP to retrieve mail from a server, then delete each message after I retrieve it. What I want to do is to check that I don;t...
    3. Another Query of Query cast error
      Just in case somebody else is getting this error I thought I'd leave this here. I have a shopping cart that is stored in a session variable. When at...
    4. CAML Query: Multiple Query Fields Issue
      I need to Create a CAML Query Dynamically with VB to a Sharepoint WebService GetListItems Method. The User Could Select 1 to X Number of IDs...
    5. BCP query out executed by xp_cmdshell works fine from query analyzer but fails from VB Component
      Hi all, I have a stored procedure which returns a vast number of record and i have to write the output into a csv file. I'm using BCP utility to...
  3. #2

    Default Re: Query of Query Error

    My guess is that Cold Fusion is interpreting the lotnum field as a date instead
    of a string. To get around that, you might want to add an additional field to
    the select clause of your initial query that prepends a letter to the lot
    number. Then, in your Q of Q, use that field in your where clause.

    Dan Bracuk Guest

  4. #3

    Default Re: Query of Query Error

    That was it.

    Thanks again.
    driggle Guest

  5. #4

    Default Re: Query of Query Error

    > My guess is that Cold Fusion is interpreting the lotnum field as a date instead
    > of a string. To get around that, you might want to add an additional field to
    > the select clause of your initial query that prepends a letter to the lot
    > number. Then, in your Q of Q, use that field in your where clause.
    *OR* just use a <cfqueryparam> to tell CF what date type it actually is
    (probably a varchar). That way you don't need to mung your data.

    --
    Adam
    Adam Cameron Guest

  6. #5

    Default Re: Query of Query Error

    Does a cfqueryparam work with a query of query?
    driggle Guest

  7. #6

    Default Re: Query of Query Error

    > Does a cfqueryparam work with a query of query?

    Yes. I'm not so cruel as to suggest something that doesn't work ;-)

    --
    Adam
    Adam Cameron Guest

  8. #7

    Default Re: Query of Query Error

    >> Does a cfqueryparam work with a query of query?
    > Yes. I'm not so cruel as to suggest something that doesn't work ;-)
    Hmmm.

    Seems there's *degrees* of working. They certainly work when telling CF
    that a value *is* a date, but seemingly not so much when telling CF that a
    string *isn't* a date, even when it clearly isn't.

    See this sample code:

    <cfset q1 = queryNew("iCol,dCol","integer,VarChar")><!--- no dates here
    --->
    <cfset queryAddRow(q1)><cfset querySetCell(q1, "iCol", 1)><cfset
    querySetCell(q1, "dCol", "2011-61-12")><!--- not a date --->
    <cfset queryAddRow(q1)><cfset querySetCell(q1, "iCol", 2)><cfset
    querySetCell(q1, "dCol", "2006-06-29")>
    <cfset queryAddRow(q1)><cfset querySetCell(q1, "iCol", 3)><cfset
    querySetCell(q1, "dCol", "2006-07-29")>
    <cfset queryAddRow(q1)><cfset querySetCell(q1, "iCol", 4)><cfset
    querySetCell(q1, "dCol", "2006-08-29")>
    <cfset queryAddRow(q1)><cfset querySetCell(q1, "iCol", 5)><cfset
    querySetCell(q1, "dCol", "2011-1-12")>

    <cfquery name="q2" dbtype="query">
    select iCol, dCol
    from q1
    where dCol = <cfqueryparam cfsqltype="cf_sql_varchar"
    value="#javacast('string', '2011-61-12')#"><!--- change '61' to '1' and it
    works --->
    </cfquery>

    <cfdump var="#q2#">

    Now... column dCol is CLEARLY not date data:
    1) I'm specifying it as VARCHAR in the query definition.
    2) The first value in it is definitely not a date.
    3) Nowhere am I treating it like a date.

    Although CF apparently knows better, and goes 'ooh... despite him saying
    it's not a date, the data not being date data, and when he uses the data,
    he specifically says "it's not a date" (and man... he's even saying that
    TWICE!)... I reckon cos SOME of the date looks kinda like a date... I know
    what I'll do!!" [and proceeds to collapse in a heap, because it decides I'm
    using dates].

    So. Looks like I'm gonna have to suck it up, and suggest you should listen
    to Dan and not me!

    --
    Adam

    (PS: I shall raise a bug with Adobe regarding this behaviour).
    Adam Cameron Guest

  9. #8

    Default Re: Query of Query Error

    Thanks for trying this. I was trying to use cfqueryparam but was having syntax issues. Just as well since you found a problem.
    Thanks for the informative post. :-)
    driggle Guest

  10. #9

    Default Re: Query of Query Error

    Did anyone try using CAST() in this instance instead of using cfqueryparam?
    According to [url]http://livedocs.macromedia.com/coldfusion/7/htmldocs/00001270.htm[/url]
    you can use CAST() in Q-of-Q to ensure the correct datatype.

    In some cases, ColdFusion MX can guess a data type that is inappropriate
    for your application. In particular, if you use columns in a WHERE clause or
    other conditional expression, the data types must be compatible. If they are
    not compatible, you must use the CAST function to recast one of the columns to
    a compatible data type. For more information on casting, see Using the CAST
    function. For more information on data type compatibility, see Understanding
    Query of Queries processing.


    Something like this perhaps? I haven't tried it myself, but it might be an
    option.

    Select *
    from Invlotquery2
    where lotnum = CAST('2011-61-12' AS varchar)

    Phil




    paross1 Guest

  11. #10

    Default Re: Query of Query Error

    > CAST

    <SLAPS HEAD>
    It was blimin' me who instigated the request for Macrmoedia to put that
    function into CFMX7 in the first place.
    </SLAPS HEAD>

    --
    Adam

    (suddenly feeling rather thick)
    Adam Cameron Guest

  12. #11

    Default Re: Query of Query Error

    Good one, Adam! Senior moment? :grin;
    paross1 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139