Debugging Queries with CFQUERYPARAM

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

  1. #1

    Default Debugging Queries with CFQUERYPARAM

    I have recently become a believer in using CFQUERYPARAM in all of my queries.
    I fully understand the benefits of their use. There is, however, one
    disadvantage that I have found. I was hoping to get some suggestions.

    If I create a query WITHOUT using CFQUERYPARAM, and the query fails, I will
    get a "nice" database error and the full text of the SQL that failed. I can
    then take the SQL and run it through an SQL editor (Oracle or otherwise) and
    get more information about the cause of the error.

    Using CFQUERYPARAM, I cannot get a full SQL statement. It is full of
    "Parameter 1", "Parameter 2", etc. Can anyone offer any suggestions of a
    simple way to debug queries that use CFQUERYPARAM?

    Given the benefits, I will use CFQUERYPARAM in all of my queries. It would,
    however, be nice to see a "dynamic SQL" statement sometimes for debugging.

    Richard7777 Guest

  2. Similar Questions and Discussions

    1. Debugging output does not appear when use Debugging IPAddresses
      I recently absorbed the task of supporting our CF MX 6.1 server. We have an app that we need to debug - the developer asked us to add her IP...
    2. cfqueryparam usage
      Hello, Ive been tightening up my querys using the cfqueryparam tag and it does also seem to help greatly with speed. Is it worth using...
    3. cfqueryparam
      Hi, I am trying to take values passed through a form and do a search based on that, but I am getting an error Error Executing Database Query....
    4. Queries Of Queries Single Quote Problem
      When using queries of queries I'm having the following issue. Select Company_ID From qry_MyQuery Where Company_NM = 'MyString''s' <----...
    5. cfqueryPARAM problem
      Viva Coldfusion Forum - 'Kudos to all who help out in the time of trouble for they shall be rescued in theirs' I am concatenating an sql statement...
  3. #2

    Default Re: Debugging Queries with CFQUERYPARAM

    It's not exactly what you want, but read this:
    "# Added result variables for the SQL statement executed (sql), the number
    of records returned (recordcount), whether the query was cached (cached),
    an array of cfqueryparam values (sqlparameters), and the list of columns in
    the returned query (columnlist)."

    From
    [url]http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=p art_cfm.htm[/url]

    This will be a big help in a lot of situations, I think.
    --

    Adam
    Adam Cameron Guest

  4. #3

    Default Re: Debugging Queries with CFQUERYPARAM

    If you're wrapping you're queries in cftry's this can be added to the cfcatch
    to
    determine what the cfqueryparams where

    <cfif StructKeyExists(cfcatch, "Sql")>
    <cfoutput>#cfcatch.Sql#<P></cfoutput>
    </cfif>
    <cfif StructKeyExists(cfcatch, "where")>
    <cfoutput>#cfcatch.where#<P></cfoutput>
    </cfif>

    The cfcatch.sql will contain something like:

    SELECT *
    FROM table
    WHERE id = (param 1)
    AND name = (param 2)

    The cfcatch.where will contain something like:

    (param 1) = [type='IN', class='java.lang.String', value='70',
    sqltype='CF_SQL_INTEGER'] ,
    (param 2) = [type='IN', class='java.lang.String', value='test',
    sqltype='CF_SQL_VARCHAR']

    It at least gives you all the information to put the queries back together.


    tconley 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