James Sleeman wrote:
> 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.

But only if you set the Isolation Level high enough. IIRC this requires 
a "Serializable" isolation level.

Jochem

______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
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