QueryGetSQL(queryname)
Last updated October 15, 2002
Version: 1 | Requires: ColdFusion MX | Library: DatabaseLib
Description:
Returns the SQL statement used to generate the specified query. Uses the coldfusion.server.ServiceFactory object used by the ColdFusion debugging service.
Return Values:
Returns a string.
Example:
<CFQUERY NAME="GetUDFCount" DATASOURCE="#Request.App.DSN#">
SELECT Count(*) as UDFCount
FROM tblUDFs
</CFQUERY>
<P>
<CFOUTPUT>
#QueryGetSQL("GetUDFCount")#
</CFOUTPUT>
Example disabled since debugging is not turned on this server.
--->
Parameters:
| Name | Description | Required |
|---|---|---|
| queryname | Name of the query you wish to return the SQL statement for. | Yes |
Full UDF Source:
<!---
Returns the SQL statement used to generate the specified query.
@param queryname Name of the query you wish to return the SQL statement for. (Required)
@return Returns a string.
@author Ben Forta (ben@forta.com)
@version 1, October 15, 2002
--->
<CFFUNCTION NAME="QueryGetSQL" RETURNTYPE="string">
<!--- Query name is required --->
<CFARGUMENT NAME="queryname" TYPE="string" REQUIRED="yes">
<!--- Initialize variables --->
<CFSET var cfdebugger="">
<CFSET var events ="">
<!--- Initialize result string --->
<CFSET var 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>
Search CFLib.org
Latest Additions
Tayo Akinmade added
arrayTrim
10 day(s) ago
Will Belden added
longTime
15 day(s) ago
James Sleeman added
quickSort
25 day(s) ago
Ben Forta added
GetHostAddress
28 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)