jeudi 8 janvier 2015

Check for table lock in conditional statement


How can I make this work?



IF( EXISTS (SHOW OPEN TABLES WHERE In_use < 2 and `Database` like 'MYDB' ) ) THEN
-- DO SOMETHING
END IF


Context


I want to run some sql statements inside a procedure, only if the table x is not locked ( because of updates or any other reason ).


I want to do this on the MySQL server side as I have clients that trigger this procedure from more than 12 machines from bash, c and c#.


So is there any way to get the table lock information in a conditional statement on the server side ?





Aucun commentaire:

Enregistrer un commentaire