Solved

Mutex table howto

Posted on 2001-06-21
5
926 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article describes some very basic things about SQL Server filegroups.
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…

757 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

17 Experts available now in Live!

Get 1:1 Help Now