Solved

Mutex table howto

Posted on 2001-06-21
5
944 Views
Last Modified: 2008-03-10
Hi all,

How do i create a mutex table in a database and ensure consistency using standard SQL.

Scenario:

Multiple clients must be able to perform the following sequence:

set mutex
read value from table
process value
update value in table
release mutex

Unique client id's are not available.

Preferable only the statements select, update, insert and delete is used. The solution must work with at least oracle and mySQL.

Regards
/S?ren




0
Comment
Question by:svanggaard
5 Comments
 
LVL 32

Expert Comment

by:bhess1
ID: 6215755
Try using the FOR UPDATE option on your SELECT statement, e.g.:

SELECT * From MyTable WHERE ID = 1 FOR UPDATE

This locks the rows, disallowing updates from other processes until they are released.

Both MySQL and Oracle support this syntax.
0
 

Author Comment

by:svanggaard
ID: 6217922
The SELECT FOR UPDATE is not supported by mySQL.

mySQL only supports locking an entire table.

Regards

/S?ren
0
 
LVL 32

Expert Comment

by:bhess1
ID: 6218992
Hmmm... according to the documentation at MySQL.Com, this is supported...

"If you are using FOR UPDATE on a table handler with page/row locks, the examined rows will be write locked. "

Researching more, this means that you will need the InnoDB version of MySQL.  If you cannot use this for some reason, then you are right - you will need an external Mutex handler of some sort.

See:  http://www.mysql.com/doc/I/n/InnoDB.html
for more info on InnoDB tables and their use.

0
 
LVL 54

Expert Comment

by:nico5038
ID: 7257289

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
 - PAQ'd and pts removed
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Nic;o)
0
 

Accepted Solution

by:
Jgould earned 0 total points
ID: 7282238
Question has been closed as per recommendation

JGould-EE Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In today’s complex data management environments, it is not unusual for UNIX servers to be dedicated to a particular department, purpose, or database.  As a result, a SAS® data analyst often works with multiple servers, each with its own data storage…
Read about achieving the basic levels of HRIS security in the workplace.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now