Twitter: raymondcamden

Address: Lafayette, LA, USA

Ask a Jedi: Working with ColdFusion's Debug Query Display and CFQUERYPARAM

10-15-2008 4,801 views ColdFusion 23 Comments

Eric asked a question I thought others might be interested in as well:

Ray, I often find it useful when a cfquery tanks to take the SQL code provided in the error, put it into my editor, and play around with the code there. However, when using cfqueryparam, this becomes a much bigger challenge because the values are not directly in the SQL query. I have to sort through the param structure and manually replace the values with (param 1) etc. Is there any way to grab the query with the param values replaced?

If you don't know what he means, he is talking about debug displays like so....

There are multiple ways you can work with this. Obviously you can cut and paste, but for anything besides a simple query, this is going to be difficult. ColdFire automatically replaces the ? when it displays the query:

Other options include additional plugins by Nathan Mische (who is running ColdFire now don't forget):

CF Debug Copy for Fire: This will work with ColdFusion's classic debug output and let you simply right click/copy into the correct format.

ColdFusion Debug SQL Explorer Extension: This is another option that works with an Eclipse plugin. CFEclipse users may prefer this one, but I haven't tried it myself. (My queries never have errors. Ever.)


These comments will soon be imported into Disqus. To add a comment, use Disqus above.
  • Quan Tran #
    Commented on 10-15-2008 at 9:15 AM
    Another option, if you have access to the server/admin, is to modify the template that outputs the debugging info.

    files in:
    cfusion\wwwroot\WEB-INF\debug\ - i'm on cf 6

    I haven't done this particular change, but i don't think it'll take much work to make that change looking at the file.

    You can make multiple files and choose which to use from the admin.
  • Commented on 10-15-2008 at 10:00 AM
    Since you run a good blog here, I wanted to share this with you
  • Stuart Moffatt #
    Commented on 10-15-2008 at 10:41 AM
    Another option is Ben Nadel's bookmarklet:
  • Commented on 10-15-2008 at 10:58 AM
    We "fixed" the ColdFusion debug templates a number of years ago to make the SQL statements copy-and-pasteable, and also to make the popup debug window not automatically pop up.

    You can get our version here:
  • Rich Rein #
    Commented on 10-15-2008 at 11:13 AM
    One thing that has always bugged me (but apparently not enough to make it a priority to work around) is that the debug output is not HTML-escaped. This is most noticable when having something like myDateColumn < '01/01/2010'. Anything from the greater than or less than sign to the end of the query is visible in the html source, but lost in the display (making it yet again hard to copy/paste queries out of your debug output.
  • Commented on 10-15-2008 at 11:40 AM
    I'll just add that there are two versions of CF Debug Copy, one for IE and one for Firefox. Both are available on RIAForge: (for IE) (for Firefox)
  • Commented on 10-15-2008 at 11:59 AM
    What is this IE you speak of?
  • Akira #
    Commented on 10-15-2008 at 1:49 PM
    The IE works great, even with IE 6.

    Ray, unfortunately there are a lot of us who are forced to use IE6 by our IT departments.
  • Commented on 10-15-2008 at 3:06 PM
    @Rich Rein: What version of CF are you on? I tested that with CF8 and it displayed just fine.
  • Commented on 10-15-2008 at 3:15 PM
    I just bought a PC with Windows Vista Home Premium and installed CF8 + SQLServer2008 on it yesterday.
    When I turned debugging on today and changed the page to Coldfire, the administrator page now says "Either the Macromedia application server(s) are unreachable or none of them has a mapping to process this request."
  • Rich Rein #
    Commented on 10-15-2008 at 3:19 PM

    My apologies, I guess that I hadn't really paid attention since our last upgrade - I am fairly confident in saying that it was broken as recently as 7?
  • Commented on 10-15-2008 at 3:21 PM
    @PS - Not sure what to say. Nathan, you know of any bug reports w/ Vista+CF8+ColdFire?

    @RR - Try with CF8. :)
  • Commented on 10-15-2008 at 3:57 PM
    @ Phillip - I'm running ColdFire on Vista Business with CF 8. If you switch back to classic debugging template does everything work as expected?
  • Commented on 10-15-2008 at 5:21 PM
    I made a standalone windows app a few months ago that does this as well, and blogged it here:
  • Commented on 10-16-2008 at 9:14 AM
    In Vista Home Premium,
    I uninstalled/reinstalled ColdFusion, turned all the debugging options on and cfide/administrator locked up again.
    So I uninstalled/reinstalled ColdFusion and turned on only "Enable Request Debugging Output" with Coldfire and now it is working.
    So turning on one of these options locks up cfide/administrator:
    Enable Robust Exception Information
    Enable AJAX Debug Log Window
    Timer Information
    Flash Form Compile Errors and Messages
    Enable Performance Monitoring

    But all is well.
  • Commented on 10-16-2008 at 9:33 AM
    To truly turn debugging on, I had to choose "Add Current" to the list of IP addresses, which added ::1.
    I seem to remember this was mentioned in Ben Forta's blog.
  • Commented on 10-16-2008 at 2:58 PM
    @Phillip - So when it locked up, with everything enabled, were you using the coldfire.cfm debugging template, or classic.cfm?
  • Brian Oeding #
    Commented on 11-03-2008 at 9:05 AM
    I installed the latest ColdFire version just now for FF 3.0.1 and it installed fine and my code runs without errors except my CF8.01/SQL Server 2005 app that uses much of the new AJAX functionality including datagrids has queries that do not get displayed in ColdFire. Actually nothing is displayed for any of the ColdFusion tabs (General, Eception Times, DB Queries ...). I'm running it all on my local computer. Anyone seen this or have a way it can be fixed? I was interested mostly from the standpoint of getting the SQL for a large query that has numerous cfqueryparam values.
  • Commented on 11-03-2008 at 10:36 AM
    @BO, @NM: Nathan, I believe the most recent versions of ColdFire supported noticing multiple requests, right?
    @BO - The issue is that - your main request didn't do anything except use Ajax stuff.

    Of course, you also want to ensure you have debugging enabled, and set to ColdFire, and that you aren't restricting to an IP that doesn't match yourself.
  • Brian Oeding #
    Commented on 11-03-2008 at 12:13 PM
    Understood. Debugging is "enabled, and set to ColdFire, and that you aren't restricting to an IP that doesn't match yourself". Would be nice if the AJAX calls could be picked up here, since this is my new environment, I'll be working with for awhile. Thanks.
  • Commented on 11-03-2008 at 1:00 PM
    @BO: I'll let Nathan respond to see if he got the support for N calls working, but you do know that you can use Firebug to see the XHR request and simply right click/load new tab.
  • Brian Oeding #
    Commented on 11-03-2008 at 1:33 PM
    I am fairly new to Firebug, but it has been invaluable in debugging my AJAX code the last couple months. I'm not familiar with the term XHR, but I assume you are referring to the GET calls in the console and if so yes, but they do not have my query embedded there that I'm aware of.
  • Commented on 11-03-2008 at 1:35 PM
    Yes, by XHR I meant AJAX. You had said you used a page that was mainly ajax based. If you want to see the debug data from an Ajax request, it may be simpler to load that request by itself. Does that part make sense? It should work - I do it all the time. Look out for a cfnodebug or some such in the URL though. You may need to remove that.