Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

How to lock a row in sybase

Avatar of sristeve
sristeve asked on
Sybase DatabaseMySQL Server
6 Comments1 Solution3264 ViewsLast Modified:
I have a storeproc which does an update of row. If the status field is  'X' it updates to 'Y'.
This storeproc can be called by multiple programs concurrently ( sqladvantage/java processes).
Only the first process that calls this program should be able to update it.
Please note that each process starts a transaction, calls this storeproc and commits.

What I have seen is that all processes that are running concurrently are able to update this row. All the processes see the value as 'X' and update it to 'Y'. The processes wait for the lock to be obtained if some other process is currenlty updating it.

Simulating the problem inside SQL Adavtage.

SQL Advantage 1 - Start Transaction
SQL Advantage 2 - Start Transaction
SQL Advantage 1 - Call update SP - 1 Row updated
SQL Advantage 2 - Call update SP - Waiting for the lock
SQL Advantage 1 - commit
SQL Advantage 2 - 1 Row Updated - ( I was hoping that there would be 0 Rows updated)
SQL Advantage 2 - commit
Avatar of grant300

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answers