Solved

Showing a status when long queries are running

Posted on 2001-06-12
10
150 Views
Last Modified: 2013-12-24
I was wondering if there was a way to display a message, or some sort of status when a page is loading with a cfquery which takes a while to run.
0
Comment
Question by:mor4eus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 1

Author Comment

by:mor4eus
ID: 6185460
Close, but maybe I didn't explain properly.  It's not the data that it's returning that is taking a long time, its the query.  I am doing a select distinct(name) on a rather large table and it is taking a while to complete the sql command.  It only returns about 30 rows of data.
0
 
LVL 11

Expert Comment

by:jimmy282
ID: 6185476
yes i agree but still this si what you want. you only wnt to display a message while the data is being loaded...these tags will solve your purpose....wont they?

Jimmy
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 1

Author Comment

by:mor4eus
ID: 6186219
I tried using these tags, but I have found out(maybe wrong) that cold fusion will process a cfquery first.  This is why it takes for ever with a long query.  The scripts you suggested work, but only when displaying the data. Not reading it. What is happening is the cfm page waits until the query finishes, then starts loading the data.  If there is lots of data returned(eg over 20000 lines) the scripts display, but they don't display until the data is received from the sql query.  It was a good idea though.
0
 
LVL 1

Author Comment

by:mor4eus
ID: 6186390
I tried using these tags, but I have found out(maybe wrong) that cold fusion will process a cfquery first.  This is why it takes for ever with a long query.  The scripts you suggested work, but only when displaying the data. Not reading it. What is happening is the cfm page waits until the query finishes, then starts loading the data.  If there is lots of data returned(eg over 20000 lines) the scripts display, but they don't display until the data is received from the sql query.  It was a good idea though.
0
 
LVL 5

Expert Comment

by:Yog
ID: 6186946
maybe u need to optimise then - have you tried running the query over a Query analyser or converting it to a stored proc etc - can u paste the query - lol
0
 
LVL 1

Author Comment

by:mor4eus
ID: 6189609
I cannot optimise the query anymore.  It runs on a large table and just has to take a while.  I have found though with ColdFusion Server 5 a command called cfflush which will work for this problem.  Maybe I will have to wait for this unless anyone has anymore good ideas.  FYI the select query chooses the distinct on only one column but over 900,000 records.
0
 
LVL 11

Expert Comment

by:jimmy282
ID: 6189687
<CFSETTING ENABLECFOUTPUTONLY="YES">
<!--- Optional Attributes --->
<CFPARAM NAME="Attributes.DISPLAY" DEFAULT="HTML">
<CFPARAM NAME="Attributes.JAVASCRIPT" DEFAULT="NO">
<CFPARAM NAME="Attributes.CHECKFOR" DEFAULT="PleaseWait">
<CFPARAM NAME="Attributes.BGCOLOR" DEFAULT="##FFFFFF">
<CFPARAM NAME="Attributes.FONTFACE" DEFAULT="Arial">
<CFPARAM NAME="Attributes.FONTSIZE" DEFAULT="2">
<CFPARAM NAME="Attributes.TITLE" DEFAULT="">
<CFPARAM NAME="Attributes.MESSAGE" DEFAULT="">
<CFPARAM NAME="Attributes.RequestTimeout" DEFAULT="">
<CFPARAM NAME="Attributes.SERVER_NAME" DEFAULT="#CGI.SERVER_NAME#">
<CFPARAM NAME="Attributes.PROTOCOL" DEFAULT="#CGI.SERVER_PORT#">
<CFIF ParameterExists(Caller.FORM.fieldnames)>
    <CFPARAM NAME="Attributes.FIELDNAMES" DEFAULT="#FORM.fieldnames#">
<CFELSE>
    <CFPARAM NAME="Attributes.FIELDNAMES" DEFAULT="">
</CFIF>

<CFSET Attributes.PROTOCOL = LCase(Attributes.PROTOCOL)>
<CFIF Attributes.PROTOCOL IS "443">
    <CFSET Attributes.PROTOCOL = "https">
<CFELSEIF Lcase(Attributes.PROTOCOL) NEQ "https">
    <CFSET Attributes.PROTOCOL = "http">
</CFIF>

<CFSET Attributes.FIELDNAMES = UCase(Attributes.FIELDNAMES)>

<CFSET Attributes.DISPLAY = Ucase(Attributes.DISPLAY)>
<CFSET Attributes.JAVASCRIPT = Ucase(Attributes.JAVASCRIPT)>

<CFIF (Attributes.JAVASCRIPT NEQ "YES") AND (Attributes.JAVASCRIPT NEQ "NO")>
    <CFSET Attributes.JAVASCRIPT = "NO">
</CFIF>

<CFIF Attributes.DISPLAY IS "JAVASCRIPT">
    <CFSET Attributes.JAVASCRIPT = "YES">
</CFIF>

<CFIF ((Trim(Attributes.TITLE) IS "") AND (IsDefined("Attributes.FIELDNAMES")) AND (Attributes.JAVASCRIPT

IS "NO")) OR (Attributes.DISPLAY IS "JAVASCRIPT")>
    <CFSET Attributes.TITLE = "Warning!">
<CFELSEIF Trim(Attributes.TITLE) IS "">
    <CFSET Attributes.TITLE = "Please Wait... Processing Request.">
</CFIF>

<CFIF ((Trim(Attributes.MESSAGE) IS "") AND (Trim(Attributes.FIELDNAMES) NEQ "") AND (Attributes.JAVASCRIPT

IS "NO")) OR (Attributes.DISPLAY IS "JAVASCRIPT")>
    <CFSET Attributes.MESSAGE = "The action you have chosen" & Chr(13) & Chr(10)>
    <CFSET Attributes.MESSAGE = Attributes.MESSAGE & "may take several minutes to complete.">
<CFELSEIF Trim(Attributes.MESSAGE) IS "">
    <CFSET Attributes.MESSAGE = "Please wait... This script is processing" & Chr(13) & Chr(10)>
    <CFSET Attributes.MESSAGE = Attributes.MESSAGE & "and may take several minutes to run.">
</CFIF>

<CFSET Query_String = CGI.QUERY_STRING>
<CFIF (Trim(Attributes.RequestTimeout) NEQ "") AND (Val(Attributes.RequestTimeout) GT 0)>
    <CFIF Len(Query_String) GT 0>
    <CFSET Query_String = Query_String & "&">
    </CFIF>
    <CFSET Query_String = Query_String & "RequestTimeout=#Attributes.RequestTimeout#">
</CFIF>

<CFSET PageToReload = "#Attributes.PROTOCOL#://#Attributes.SERVER_NAME##CGI.SCRIPT_NAME#?#Variables.Query_String#">
<CFIF Right(PageToReload,1) NEQ "?">
    <CFSET PageToReload = PageToReload & "&">
</CFIF>
<CFSET PageToReload = PageToReload & Attributes.CHECKFOR & "=OK">

<CFIF CGI.HTTP_REFERER IS "">
    <CFSET HTTP_REFERER = "#Attributes.PROTOCOL#://#Attributes.SERVER_NAME#/">
<CFELSE>
    <CFSET HTTP_REFERER = CGI.HTTP_REFERER>
</CFIF>

<CFIF Trim(Attributes.FIELDNAMES) NEQ "">
    <CFSET strHiddenForm = "<FORM ACTION=""#Variables.PageToReload#"" METHOD=""POST"" NAME=""cfPleaseWait"">"

& Chr(13) & Chr(10)>
    <CFLOOP INDEX="strVar" LIST="#Attributes.FIELDNAMES#" DELIMITERS=",">
         <CFSET strHiddenForm = strHiddenForm & "<INPUT TYPE=""HIDDEN"" NAME=""#strVar#"" VALUE=""#Evaluate(strVar)#"">"

& Chr(13) & Chr(10)>
    </CFLOOP>
    <CFIF Attributes.JAVASCRIPT IS "NO">
         <CFSET strHiddenForm = strHiddenForm & "<CENTER><INPUT TYPE=""Submit"" VALUE=""Click to Continue""></CENTER>"

& Chr(13) & Chr(10)>
    </CFIF>
    <CFSET strHiddenForm = strHiddenForm & "</FORM>" & Chr(13) & Chr(10)>
</CFIF>

<CFIF (IsDefined("URL.#Attributes.CHECKFOR#") IS "No") AND (Attributes.DISPLAY IS "JAVASCRIPT")>

<CFOUTPUT>
<HTML>
<HEAD>
    <TITLE>#Attributes.TITLE#</TITLE>
</HEAD>
<BODY BGCOLOR="#Attributes.BGCOLOR#"<CFIF Trim(Attributes.FIELDNAMES) NEQ ""> onLoad="this.document.forms[0].submit()"</CFIF>>

<CFIF Trim(Attributes.FIELDNAMES) NEQ "">
#strHiddenForm#
</CFIF>

<SCRIPT LANGUAGE="JavaScript">
<!--
result = confirm('#REReplace(Attributes.MESSAGE, "#Chr(13)##Chr(10)#", "\n", "ALL")#\n\nClick "OK" to

continue,\nclick "CANCEL" to go back');
if( result==true ) {
<CFIF Trim(Attributes.FIELDNAMES) NEQ "">
    this.document.forms[0].submit();
<CFELSE>
    self.location = '#Variables.PageToReload#';
</CFIF>
} else {
    self.location = '#Variables.HTTP_REFERER#';
}
//-->
</SCRIPT>

</BODY>
</HTML>
</CFOUTPUT>


<CFELSEIF (IsDefined("URL.#Attributes.CHECKFOR#") IS "No") AND (Attributes.DISPLAY IS "HTML")>


<CFOUTPUT>
<HTML>
<HEAD>
    <TITLE>#Attributes.TITLE#</TITLE>
<CFIF Trim(Attributes.FIELDNAMES) IS "">
    <META HTTP-EQUIV="REFRESH" CONTENT="0; URL=#Variables.PageToReload#">
</CFIF>
</HEAD>
<BODY BGCOLOR="#Attributes.BGCOLOR#"<CFIF Trim(Attributes.FIELDNAMES) NEQ ""> onLoad="this.document.forms[0].submit()"</CFIF>>


<FONT FACE="#Attributes.FONTFACE#" SIZE="#Attributes.FONTSIZE#">

<CENTER><H4>#Attributes.TITLE#</H4></CENTER>

<P><CENTER><TABLE WIDTH="300" BORDER="0"><TR><TD><FONT FACE="#Attributes.FONTFACE#" SIZE="#Attributes.FONTSIZE#">
#Attributes.MESSAGE#
</FONT></TD></TR></TABLE></CENTER></P>

<CFIF Trim(Attributes.FIELDNAMES) NEQ "">
#strHiddenForm#
</CFIF>

<CFIF (Trim(Attributes.FIELDNAMES) NEQ "") AND (Attributes.JAVASCRIPT IS "YES")>
<SCRIPT LANGUAGE="JavaScript">
<!--
    //document.cfPleaseWait.submit()
    //this.document.forms[0].submit();
//-->
</SCRIPT>
</CFIF>

</FONT>
</BODY>
</HTML>
</CFOUTPUT>


</CFIF>

<CFIF IsDefined("URL.#Attributes.CHECKFOR#") IS "No">
    <CFABORT>
</CFIF>

<CFSETTING ENABLECFOUTPUTONLY="NO">

i hope it helps

jimmy
0
 
LVL 11

Accepted Solution

by:
jimmy282 earned 300 total points
ID: 6189688
here is a working example
p.s. the tag name is pleasewait.cfm


<!--- This prints the wait message --->
<CF_PleaseWait DISPLAY="HTML">

<CFIF ParameterExists(URL.PleaseWait)>
    <CFSET TimeStarted = Now()>
    <!--- This loop should take a little time to run --->
    <CFLOOP CONDITION="DateDiff('s', TimeStarted, Now()) LTE 5">

    </CFLOOP>
</CFIF>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<HTML>
<HEAD>
    <TITLE>CF_PleaseWait Example Page</TITLE>
</HEAD>

<BODY BGCOLOR="#FFFFFF" VLINK="#800000" ALINK="#800000">
<FONT FACE="Arial" SIZE="2">

<CENTER><H3>CF_PleaseWait Example</H3></CENTER>

<P>This is an example of how CF_PleaseWait can be used. CF_PleaseWait
is easy to implement, and is designed to take care of of over-anxious
users who insist on repeatively clicking on hyperlinks and submit buttons
because they don't see an immediate result.</P>

<P>If you have any questions, comments or bugs to reportplease
e-mail me at <A HREF="mailto:drizzt@erinet.com">drizzt@erinet.com</A>.</P>

<FORM ACTION="example.cfm" METHOD="POST">
<CFPARAM NAME="Name" DEFAULT="">
<CFOUTPUT><INPUT TYPE="Text" NAME="Name" VALUE="#Name#"></CFOUTPUT>
<INPUT TYPE="Submit">
</FORM>

</FONT>
</BODY>
</HTML>
0
 
LVL 1

Author Comment

by:mor4eus
ID: 6189791
This is great.  Thanks jimmy282.  BTW here is their site.
http://www.pengoworks.com/index.cfm?action=cfPleaseWait
0

Featured Post

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question