Solved

Mutex table howto

Posted on 2001-06-21
5
989 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 32

Expert Comment

by:Brendt Hess
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:Brendt Hess
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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

622 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