Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Mutex table howto

Posted on 2001-06-21
5
Medium Priority
?
997 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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

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…
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

688 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