Skip navigation
CarlMarket
Currently Being Moderated

How do I Output SQL query (cfquery) to screen

May 1, 2006 11:34 AM

I'd like to output the completed SQL Query that I'm writing to CFQuery to the screen so I can see what the report is querying the database.

I tried <cfoutput>#myquery#</cfoutput> but that didn't work.
 
Replies
  • Currently Being Moderated
    May 3, 2006 2:26 PM   in reply to CarlMarket
    <cfquery>
    some query
    <cfabort>
    </cfquery>
     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2006 7:16 PM   in reply to CarlMarket
    CarlMarket wrote:
    > I'd like to output the completed SQL Query that I'm writing to CFQuery to the
    > screen so I can see what the report is querying the database.
    >
    > I tried <cfoutput>#myquery#</cfoutput> but that didn't work.


    in cf7 you can get several bits of of metadata about a cfquery's resultset:

    result_name.sql: The SQL statement that was executed.
    result_name.recordcount: Current row of query that cfoutput is processing.
    result_name.cached: True if the query was cached; False otherwise.
    result_name.sqlparameters: An ordered Array of cfqueryparam values.
    result_name.columnList: Comma-delimited list of the query columns.
    result_name.ExecutionTime: Cumulative time required to process the query.

    in your case, replace "result_name" w/"myquery".

     
    |
    Mark as:
  • Currently Being Moderated
    May 8, 2006 8:19 AM   in reply to CarlMarket
    It sounds like you want to output the result set of the query.

    One way:
    <cfdump var="#myquery#">
    Another way:
    <cfoutput query="myquery">
    #[Column1]# #[Column2]# #[Column3]# (etc...) <br>
    </cfoutput>
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points