Just tested it, 1000 INSERTS, SQL Server 7.0, both ways

2584 milliseconds as 

<CFLOOP FROM="1" TO="1000" INDEX="i">
<CFQUERY NAME="q_addNewAttributeList"
                                DATASOURCE="#request.DSN#"
                                USERNAME="#x#"
                                PASSWORD="#y#">
        
                                                
                INSERT INTO             dbo.vehicleSelection
        
(customerID,vehicleID,callsign,registration,cfid,cftoken)
                VALUES                  (13,
                                                11,
                                                '2',
                                                '3',
                                                30,
                                                345678)
        
        
</CFQUERY>
</CFLOOP>

and 

991 milliseconds as 

<CFQUERY NAME="q_addNewAttributeList"
                                DATASOURCE="#request.DSN#"
                                USERNAME="#x#"
                                PASSWORD="#y#">
        <CFLOOP FROM="1" TO="1000" INDEX="i">
                                                
                INSERT INTO             dbo.vehicleSelection
        
(customerID,vehicleID,callsign,registration,cfid,cftoken)
                VALUES                  (13,
                                                11,
                                                '2',
                                                '3',
                                                30,
                                                345678)
        </CFLOOP>
        
</CFQUERY>

J





-----Original Message-----
From: Gyrus [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 07, 2002 12:42 PM
To: CF-Talk
Subject: Re: looping inside cfquery - brain on vacation


> Maybe this?  Loop around the <cfquery>
> 
> <cfloop query="theQuery">
>    <cfquery name="blah" datasource="blah">
>       INSERT INTO Table
>       (Field)
>       VALUES ('#theQuery.FieldValue#')
>    </cfquery>
> </cfloop>

Just out of interest, does anyone know the performance
issues between looping round inside <cfquery> to insert
multiple records, and looping round *outside*, running
the <cfquery> tag multiple times?

I didn't know you *could* stick one SQL statement
after another inside <cfquery> until seeing this thread.
Is this more efficient?

- Gyrus

~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- [EMAIL PROTECTED]
work: http://www.tengai.co.uk
play: http://www.norlonto.net
- PGP key available
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

______________________________________________________________________
Why Share?
  Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation · $99/Month · Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to