I am looking for a solution to outputing a query to a CSV file.

I am currently querying the database, and running through the results and
storing them in a string.  Once I have stored 500 results I append them to
the CSV file and reset the string.

-----Code------
<CFQUERY NAME="getUserDetails">
    Query database
</CFQUERY>

<CFOUTPUT QUERY="getUserDetails">
    <CFSET csvstring=csvstring &
"#id#,#replace(first_name,',','ALL')#,#replace(last_name,',','ALL')#,#replac
e(email,',','ALL')#,#replace(postcode_P1,',','ALL')#"& chr(10)>
    <CFIF #count# EQ 500 OR #getUserDetails.CurrentRow# EQ
#getUserDetails.RecordCount#>
       <CFFILE ACTION="APPEND" FILE="thecsvfile.csv" OUTPUT="#csvstring#"
ADDNEWLINE="No">
       <CFSET count=0>
       <CFSET csvstring="">
  </cfif>
  <CFSET count=#count#+1>
</CFOUTPUT>

------Code------

The query currently returns 100,000 records, and takes about 5 seconds to
process but the page keeps timing out.  The timeout on the server is 2
minutes, which I dont want to increase.

I need this process to be performed as quickly as possible, under 2 minutes.
I know I could increase the timeout for the page by calling the page using
'requesttimeout' in the URL.

Any suggestions would be grateful.

thanks,

Colin Murphy

http://www.colin-murphy.co.uk


______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to