>> you need to use cftry to catch any errors and perform a rollback...

no, Taco, you don't *have* to. Have a read of that quote from
cfczone.org I mentioned

I knocked up a quick test to prove it once and for all

inside my method "DeleteGlobalOccupationType()" I put this:

<cfif data.occ_code EQ "xx3"><cfthrow></cfif>

and when this ran, all the inserts rolled back. fresh as a daisy!

the outside try/catch is the only one used (well, something has to
handle the error otherwise it goes to the browser)

<cfset data.occ_code = "xx" /> 
<cfset data.occ_desc = "xxxxxxxx" />

<cftry>                                         
<cftransaction>                 
        <cfloop from="1" to="4" index="ii">
                <cfset data.occ_code =  "xx" & ii />
                <cfset result = AddGlobalOccupationType("20", data) /> 
                <cfset result = DeleteGlobalOccupationType("20", data)
/>
        </cfloop>
</cftransaction>        
                                
        <cfcatch type="Any">
                <!--- notify: transaction rolled back --->
        </cfcatch>
</cftry>        

now, I haven't tested this under load nor tried to call an external
CFC's method but I don't think it should be a problem.


I wonder if it answers Andrew's question?


cheers
barry.b






-----Original Message-----
From: Taco Fleur [mailto:[EMAIL PROTECTED] 
Sent: Thursday, 29 July 2004 1:46 PM
To: CFAussie Mailing List
Subject: [cfaussie] RE: CFTransaction and CFC's


So basically this is saying

<cftransaction isolation="serializable">

<cfquery ...>
statement 1
statement 2
statement 3
</cfquery>

</cftransaction>

when it errors rolls back all three statements.

But when you have

<cftransaction action="begin" isolation="serializable">

<cftry>
<cfquery ...>
statement 1
</cfquery>
        <cfcatch><cfset error = true></cfcatch>
</cftry>

<cftry>
<cfquery ...>
statement 2
</cfquery>
        <cfcatch><cfset error = true></cfcatch>
</cftry>

<cftry>
<cfquery ...>
statement 3
</cfquery>
        <cfcatch><cfset error = true></cfcatch>
</cftry>

<cfif error>
<cftransaction action="rollback"
<cfelse>
<cftransaction action="commit"
</cfif>

</cftransaction>

you need to use cftry to catch any errors and perform a rollback...

-----Original Message-----
From: Barry Beattie [mailto:[EMAIL PROTECTED]
Sent: Thursday, 29 July 2004 1:38 PM
To: CFAussie Mailing List
Subject: [cfaussie] RE: CFTransaction and CFC's


>> the point is that I use the cftransaction because

>> there is a loop of 3 inserts and if one fails

>> they all need to fail

from a thread I started on cfczone.org

http://www.mail-archive.com/[EMAIL PROTECTED]/msg05876.html

<snip>

> Dave, I noticed (in a houseoffusion post) you shy away from

> try/catch within a transaction. how come?

It's usually not necessary, especially within the commonly used example
that
is posted over and over again, in which an exception is thrown and
caught
within the CFTRANSACTION. If you have multiple queries using the same
database connection within a CFTRANSACTION, and one of them fails,
there's
no need to catch that failure and issue a rollback, as the CFTRANSACTION
tag
will do that for you

</snip>

hope that helps
barry.b



-----Original Message-----
From: Andrew Scott [mailto:[EMAIL PROTECTED]

Sent: Thursday, 29 July 2004 1:27 PM
To: CFAussie Mailing List
Subject: [cfaussie] RE: CFTransaction and CFC's

Barry,

You do have almost the same warped humour as Scott Barnes!!

Anyway the data is critical but not as critical as others, the point is
that
I use the cftransaction because there is a loop of 3 inserts and if one
fails they all need to fail so that is why I have it inside a cftry
block.

Yeah I must admit I have been also wondering about this for some time,
never
had any issues with it as I have in the last 5 years been using SQL
Server
and never did anything much before that like this.

My point I guess is if 2 people were to hit this same query at the same
time, would I need a serialization on this transaction block if I used
the
@@Identity I guess I'll leave the serialization in for now on it and
keep an
eye on how it works!!




Regards
Andrew Scott
Technical Consultant

NuSphere Pty Ltd
Level 2/33 Bank Street
South Melbourne, Victoria, 3205

Phone: 03 9686 0485  -  Fax: 03 9699 7976


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Barry
Beattie
Sent: Thursday, 29 July 2004 1:19 PM
To: CFAussie Mailing List
Subject: [cfaussie] RE: CFTransaction and CFC's


so you're using SQLServer as a db? that's the only db I know of that
knows
@@identity AND have multiple SQL statements in the same cfquery block.

in this case, because they are in the same cfquery you probably wouldn't
even need a transaction.

mind you, that's assuming that:

<cfquery> == conn.open(dsn)
</cfquery> == conn.execute(SQL); conn.close()

that's the point I was trying to make: without knowing what the
underlying
java is doing, you have no way of knowing for certain.

I was asking Gary Menzel about this (he has ADO/MS knowledge so he
understood what I was talking about). He doesn't trust doing it this way
at
all. They work with mission critical systems (other peoples $$$) and
they
generate their own UUID's  - gave up on @@identity as a possible hole
for
this very reason. Works fine with ADO's connection objects but anything
else
is a mystery.

I'm sorry this isn't a definative answer. I've been asking similar
questions
for a while and have not gotten a concrete answer. I've only bored you
to
tears with this because no one else has bothered to give a more accurate
answer (today or in the past - and I *have* looked). I was hoping some
of
the background knowledge might help towards a more specific answer to
your
question because I (no anyone else it seems) can't give you one.

HOWEVER...

99.99% of the time you should be able to get away without a transaction
(being in the same cfquery block). You could possibly get away with less
strong isolation than serializable (if forced to using multi cfquery's
and
cftransaction). Everyone I've asked on CFCZone.org list says it should
be
fine - no one goes to any great lengths to ensure data integrity. Hell,
most
people don't even bother with cftransaction!

but this isn't the 100% answer you were looking for. Sorry.


mate, just go ahead and do it. by the time it errors (hopefully never),
you
should be sipping pina coladas at Acapulco!

cheers
barry.b


---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
[EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/


---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
[EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Register now for the 3rd National Conference on Tourism Futures, being
held in Townsville, North Queensland 4-7 August - www.tq.com.au/tfconf

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
[EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/


---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to