Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show SQL command (syntax)

Status
Not open for further replies.

MBaraz

Programmer
Jul 9, 1999
20
0
0
US
Anybody know how to show the SQL that was actually sent to the database from a CFQUERY? For example:
<CFSET FldVal = "BIG">
<CFQUERY name="qry_See_Code">
SELECT * FROM myTable
WHERE aCol = '#FldVal#'
</CFQUERY>

I want to code something like:
<CFOUTPUT>#qry_See_Code.SQL#</CFOUTPUT>

and see:
SELECT * FROM myTable
WHERE aCol = 'BIG'

There are a couple query results you can display, e.g. queryname.recordCount, etc. What about the actual SQL syntax? Seems pretty basic.

TIA...
Michael

--
Michael Baraz
Building data-driven, high-performance, massively-scaleable, infinitely extensible, über
websites
 
Is this for you to see or for your visitors?

If it's just for you, switch on debugging within CF. If it's for your visitors, duplicate the code.

Hope this helps

Wullie

YetiHost - Quality Coldfusion 7/Windows Hosting

The pessimist complains about the wind. The optimist expects it to change. The leader adjusts the sails. - John Maxwell
 
I have debugging turned on but you only get the benefit if the query is on the page you finish... also, I wanted to writ it to a log for some testing I am doing. Duplicating the code seems crude, though I have been doing it up till I have a hairy insert that I just figured there is a better way.

This is my first real hard stop since using CF4 since 1999 on an obvious, useful, feature that there is no really decent work-around. Oh well.

Thanx...

--
Michael Baraz
Building data-driven, high-performance, massively-scaleable, infinitely extensible, über
websites
 
I am doing a large ETL type import, reading XLS file and pushing to all DB tables. I want to log all the inserts for validation and tracability. I have the @@IDENTITY valie and all the substitution variable values but not in a tidy display. I could do a save as with the action page debug values but this is going to be productionized and I want to be able to audit it for the short term.

Thanx...
Michael

--
Michael Baraz
Building data-driven, high-performance, massively-scaleable, infinitely extensible, über
websites
 
in CFMX 7 the cfquery tag has a new attribute called 'result'. you assign it the variable name you want to give it, then use it however you wish.
Code:
<cfquery datasource="#foo#" name="#bar#" result="#myResult#">
....
</cfquery>

<cfdump var="#myResult#">
There are a few variables it gives you back, the SQL that was ran will be in there. BUT, if you use cfqueryparam the values will be shown as '?' instead of the actual value sent.

=========================================
Don't sweat the petty things and don't pet the sweaty things.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top