Depend on what the transaction is for.  If each iteration is a atomic action
(adding multiple users), then inside would work.  If each iteration is one
part of a process (recording line items on an order), then outside is a
must.

I'd say probably put it outside, that way if any of the inserts fail,
they'll all roll back, and so you can refresh the page without double
inserting the ones before the error.  Of course, bigger transactions put
more load on the DB, but to me, that's what computers are for, working
really hard to make my life easier.

Cheers,
barneyb

> -----Original Message-----
> From: Steve Nelson [mailto:[EMAIL PROTECTED]
> Sent: Thursday, June 10, 2004 11:16 AM
> To: CF-Talk
> Subject: cftransaction inside or outside cfloops?
>
> Which is better and why?
>
>  
>
> <cfloop query="whatever">
>
>             <cftransaction>
>
>                         <cfquery>insert....</cfquery>
>
>                         <cfquery>insert....</cfquery>
>
>                         <cfquery>insert....</cfquery>
>
>             </cftransaction>
>
> </cfloop>
>
>  
>
> Vs.
>
>  
>
> <cftransaction>
>
> <cfloop query="whatever">
>
>                         <cfquery>insert....</cfquery>
>
>                         <cfquery>insert....</cfquery>
>
>                         <cfquery>insert....</cfquery>
>
> </cfloop>
>
> </cftransaction>
>
>  
>
> Steve Nelson
>
>
>
>
>
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to