Solved

Showing a status when long queries are running

Posted on 2001-06-12
10
144 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
  • 5
  • 4
10 Comments
 
LVL 11

Expert Comment

by:jimmy282
ID: 6184941
0
 
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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Scale it in WD Gold

With up to ten times the workload capacity of desktop drives, WD Gold hard drives employ advanced technology to deliver among the best in reliability, capacity, power efficiency and performance.

Join & Write a Comment

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now