Skip to main content
December 29, 2010
Question

very strange ColdFusion problem

  • December 29, 2010
  • 3 replies
  • 2159 views

what would cause a page with a <cfquery> to return no results... yet when i copy that SQL query generated that returned 0 results from the

debugging output and paste it into a DBA tool (like TOAD) and run it, it returns results.

i've even been able to copy the SQL output... create a test file with just this <cfquery> and SQL call... and the test file in fact outputs results. yet this 1 CF template always returns 0 results! i'm pulling my hair out here. any help is greatly appreciated.

    This topic has been closed for replies.

    3 replies

    Inspiring
    December 30, 2010

    Are you doing the CFDUMP immediately after the CFQUERY call, ie the immediately following line? Have you got CF debugging on? And is that reporting zero records being returned?

    If you extract the SQL as per your previous example and run it in a CFQUERY tag immediately following the first CFQUERY, do both get zero records, or just the latter one return records?

    --

    Adam

    December 30, 2010

    yes the cfdump is immediately after the query. CF debugging IS turned on. the reporting in deubbing shows 0 records returned.

    just the latter one returns the results... not the first SQL (although its exactly the same). the only difference between the first and the last is that the first SQL has some loops and if statements within the cfquery and the second is just the SQL that was generated from the first run but no differences in the ACTUAL sql in the debugging info

    Inspiring
    December 30, 2010

    This is ringing a bell now.

    I can't remember the exact detail, and am sitting in a pub in the middle of the wilds of Oxfordshire (such as Oxf. has wilds), doing this on my phone so don't have any code with me, but... Control characters. We ended up with a CFQUERY tag outputting a vertical tab or something like that (copy and pasted from elsewhere), and that was causing "unexpected results" with Oracle.

    Maybe check that sort of thing.

    --

    Adam

    Participating Frequently
    December 29, 2010

    Are you sure that the SQL you think is being generated is the SQL you're

    intending to generate? Try dumping out the query and check the SQL being

    generated.

    Are any queries working? Without knowing more, it's difficult to suggest

    much else.

    December 29, 2010

    i just tried dumping the query. in the output i find the SQL section. it is what i am trying to generate. no errors are thrown. i literally copy the SQL that is dumped out (with the result set being 0)... paste it into a SQL app (in this case TOAD)... run it and results are returned!

    as i mentioned i can take this SQL... create a test.cfm CF page on my server... paste the EXACT sql generated into the test.cfm file... run it and there are results returned.

    i do not have any caching going on in this particular <cfquery> either. any suggestions?

    Legend
    December 29, 2010

    Double check the datasource to make sure it is pointing to the server and database you are expecting it to point to. Also check the SQL user and make sure it has [dbo] access (assuming MS-SQL). I spent time diagnosing a similar issue just to find out that my datasource was pointed to a testing database.

    Without more details like the actual query, I can't think of anything else.

    WolfShade
    Legend
    December 29, 2010

    Can't really say without seeing code.  It could be anything.  I've run into this, myself, many times.  Each time was a different reason.

    ^_^