Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to display sql query in web browser

New Here ,
Feb 15, 2021 Feb 15, 2021

Please let me know how to display the query written in cold fusion page on web browser.

195
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 15, 2021 Feb 15, 2021

I'm not entirely clear what you're asking. If you want to output the actual SQL statement, it's a property of the CFQUERY resultset, like so:

 

<cfquery name="sample" result="sampleResult" ...>

select * from tblSample

</cfquery>

 

<cfoutput>#sampleResult.sql#</cfoutput>

 

If on the other hand, you want to output the resultset itself, you use the QUERY attribute of CFOUTPUT:

 

<cfquery name="books" ...>

select bookId, name, author from tblBooks

</cfquery>

 

<cfoutput query="books">

#name#, #author#<br>

</cfoutput>

 

Dave Watts, Eidolon LLC

Dave Watts, Eidolon LLC
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 16, 2021 Feb 16, 2021

ColdFusion comes with a built-in datasource called cfartgallery. So, if  you open the following page, it will display the query in the browser.

 

testPage.cfm

<cfquery datasource="cfartgallery" name="testQuery">
select *
from artists
</cfquery>

<cfdump var="#testQuery#">

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 18, 2021 Feb 18, 2021
LATEST

Thank a lot BKBK and others for the solutions provided by you all.  I am trying to print the dynamic query which i will writing in my .cfm page on to the browser.  Will test the sample code provided by BKBK.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources