Execution time is easy, just use CFQUERY.ExecutionTime. Getting the SQL
statement is harder, but, if you are using CFMX and have debugging
turned on, here is a function that will do it:


<!--- Get a query's SQL statement --->
<CFFUNCTION NAME="QueryGetSQL" RETURNTYPE="string">

        <!--- Query name is required --->
        <CFARGUMENT NAME="queryname" TYPE="string" REQUIRED="yes">

        <!--- Initialize result string --->
        <CFSET result="">

        <!--- Requires debug mode --->
        <CFIF IsDebugMode()>

                <!--- Use debugging service --->
                <CFOBJECT ACTION="CREATE"
                          TYPE="JAVA"
                            CLASS="coldfusion.server.ServiceFactory"
                            NAME="factory">
                <CFSET cfdebugger=factory.getDebuggingService()>

                <!--- Load the debugging service's event table --->
                <CFSET events = cfdebugger.getDebugger().getData()>

                <!--- Get SQL statement (body) for specified query --->
                <CFQUERY DBTYPE="query" NAME="getquery" DEBUG="false">
                SELECT body
                FROM events
                WHERE type='SqlQuery' AND name='#queryname#'
                </CFQUERY>
                
                <!--- Save result --->
                <CFSET result=getquery.body>
        
        </CFIF>
        
        <!--- Return string --->
        <CFRETURN result>

</CFFUNCTION>





-----Original Message-----
From: Voris, Jim [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, June 20, 2002 1:52 PM
To: CF-Talk
Subject: How to Access Debugging info (Queries and Execution Time) progr
ammatically


Is there a way to access Queries and Execution Time that are part of the
debugging information programattically?  

CF_Dump, can get pretty much everything important in the parameters
piece, but it would be nice, say in an error handling script to get an
email with all of the information that's contained in the debug info.
(not just the error and variable information).

______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to