What it means to you as a developer is essentially that however many queries
you do inside a
<CFSTRANSACTION></CFTRANSACTION>
 block they will ALL be executed at the same time (well, they won't
strictly, but it will look that way to you).  Generally you use them to
maintain database & query integrit, think of this (most common) example...

You have two processes, both are trying to insert into a database table,
before they do they must figure out what the next "key" value to use is but
querying the database, adding to the key it got from the query and using
that in the insert... each process looks like tihs.

Query 1 - get key
Add to key
Query 2 - insert record using key

Now let's say process one comes in, it runs query 1 and adds to the key,
then the task scheduler kicks in, switches out process one and switches in
process two, process two runs query 1 and adds to the key - but because
process one hasn't yet run query 2, process two has calculated the same key
as process one !  One of those processes has to fail now because you can't
have the same key twice.

If this was wrapped in a transaction then Query 1 and Query 2 would be
grouped togethor, we are assured that they execute "at the same time" and
thus there is no way process two can get the same key as process one.

The other main reason to use a transaction is if you want to "rollback" to
the point before you started the transaction if something goes wrong
inside... CF will automatically roll back if it generates an (uncaught)
exception - some bad SQL for instance.

The level of "locking" that a transaction induces is totally dependant on
the database, and some databases do not support transactions at all (MySQL I
believe is in this group) leaving all locking up to the developer.

----- Original Message -----
From: "Charles Nahm" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Saturday, April 20, 2002 7:22 AM
Subject: Using <cftransaction></cftransaction>... Why?


> Are cftransaction tags necessary for certain types of queries (e.g.
queries
> involving Merant driver access to a DBaseIII database?).
>
> I am working with some code from the past and I notice the <cftransaction>
> tags in some areas but not in others.  Recently I have added more
> stress/queries to the DBaseIII databases and am noticing big slowdowns in
> the processes that require access to those files...
>
> In:
>
>
http://www.cfcertification.com/cfdocs/CFML_Language_Reference/2_ColdFusion_T
> ags/lr2_098.htm
>
> They say it can be used to group multiple transactions into one single
> business event.  What does that mean?  Does this mean the database will be
> locked out until all the functions within the <cftransaction> tags are
> finished?  Is this a requirement for certain types of db's?
>
> Any help/ideas appreciated, you people have been amazing.  Thanks.
>
> Charles
>
> 
______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
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