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

This post is more than 2 years old.

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.)

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by Quan Tran posted on 10/15/2008 at 6:15 PM

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.

Comment 2 by Raul Riera posted on 10/15/2008 at 7:00 PM

Since you run a good blog here, I wanted to share this with you

http://blogactionday.org/

Comment 3 by Stuart Moffatt posted on 10/15/2008 at 7:41 PM

Another option is Ben Nadel's bookmarklet:

http://www.bennadel.com/blo...

Comment 4 by Leon Miller-Out posted on 10/15/2008 at 7:58 PM

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:
http://blog.singlebrook.com...

Comment 5 by Rich Rein posted on 10/15/2008 at 8:13 PM

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.

Comment 6 by Nathan Mische posted on 10/15/2008 at 8:40 PM

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:

http://cfdebugcopie.riaforg... (for IE)
http://cfdebugcopy.riaforge... (for Firefox)

Comment 7 by Raymond Camden posted on 10/15/2008 at 8:59 PM

What is this IE you speak of?

Comment 8 by Akira posted on 10/15/2008 at 10: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.

Comment 9 by Raymond Camden posted on 10/16/2008 at 12:06 AM

@Rich Rein: What version of CF are you on? I tested that with CF8 and it displayed just fine.

Comment 10 by Phillip Senn posted on 10/16/2008 at 12:15 AM

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."

Comment 11 by Rich Rein posted on 10/16/2008 at 12:19 AM

@Ray-

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?

Comment 12 by Raymond Camden posted on 10/16/2008 at 12:21 AM

@PS - Not sure what to say. Nathan, you know of any bug reports w/ Vista+CF8+ColdFire?

@RR - Try with CF8. :)

Comment 13 by Nathan Mische posted on 10/16/2008 at 12:57 AM

@ Phillip - I'm running ColdFire on Vista Business with CF 8. If you switch back to classic debugging template does everything work as expected?

Comment 14 by Nathan Strutz posted on 10/16/2008 at 2:21 AM

Ray,
I made a standalone windows app a few months ago that does this as well, and blogged it here:
http://www.dopefly.com/tech...

Comment 15 by Phillip Senn posted on 10/16/2008 at 6:14 PM

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.

Comment 16 by Phillip Senn posted on 10/16/2008 at 6:33 PM

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.

Comment 17 by Nathan Mische posted on 10/16/2008 at 11:58 PM

@Phillip - So when it locked up, with everything enabled, were you using the coldfire.cfm debugging template, or classic.cfm?

Comment 18 by Brian Oeding posted on 11/3/2008 at 8:05 PM

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.

Comment 19 by Raymond Camden posted on 11/3/2008 at 9:36 PM

@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.

Comment 20 by Brian Oeding posted on 11/3/2008 at 11: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.

Comment 21 by Raymond Camden posted on 11/4/2008 at 12:00 AM

@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.

Comment 22 by Brian Oeding posted on 11/4/2008 at 12:33 AM

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.
BTO

Comment 23 by Raymond Camden posted on 11/4/2008 at 12:35 AM

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.