Quantcast
Channel: Adobe Community: Message List - ColdFusion
Viewing all articles
Browse latest Browse all 21760

Re: Database locking

$
0
0

I would also go for a database lock. I see no problem with sequential queries. After all, you will be locking tables, not database sessions. Also, lock will be the first instruction you send to the database, and unlocking the last. That is, something like

 

Lock

Query 1

Query 2

Unlock

 

Here follows an example I have just whipped up in MySQL. The table names are animals and birds. The lock types are read for animals and write for birds.

 

<cfquery name="q1" datasource="cfmx_db">

LOCK TABLES animals READ, birds WRITE

</cfquery>

 

<cfquery name="q2" datasource="cfmx_db">

SELECT * FROM animals

LIMIT 5

</cfquery>

 

<cfquery name="q3" datasource="cfmx_db">

SELECT * FROM birds

LIMIT 3

</cfquery>

 

<cfquery name="q4" datasource="cfmx_db">

UNLOCK TABLES

</cfquery>

 

<cfdump var="#q2#">

<cfdump var="#q3#">


Viewing all articles
Browse latest Browse all 21760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>