?
Solved

Showing a status when long queries are running

Posted on 2001-06-12
10
Medium Priority
?
153 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
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
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 1200 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

Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

Question has a verified solution.

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

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…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

719 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