|Perl: the Markov chain saw|
LOCK TABLES using Perl in MySQLby sdyates (Scribe)
|on Oct 12, 2001 at 23:19 UTC||Need Help??|
sdyates has asked for the wisdom of the Perl Monks concerning the following question:
Well, I made this great little application that writes to and updates a table in MySQL, but now I have more than one user making updates, and while I feel that the chance of a corruption is slim, I want to be able to lock the table for all other users(threads), write the information to the DB, then unlock the tables.
I am using DBD::mysql. Below is an sample of the code I used to write to the DB:
Simple stuff! Yet if I copy these lines above and use LOCK TABLES table read, I cannot write as I am locking all data.
I understand I have a two part issue here:
2) Determining the proper syntax of the lock and unlock to get me where I need to be.
For Perl, do I just copy the two lines of code, replace $SQLCommand with appropriate lock statement. Use the same two lines of code to write my SQLCommand. Then, use the same two lines of code replacing $SQLCommand again with UNLOCK TABLES?
Also if any one has some sample SQL lines on locking procedures *I know this is not a MySQ site, but what the heck, it is related. Thanks folks.
Edited: Sun Oct 14 07:11:57 2001, footpad - Added/Corrected <P> tags and removed repeated paragraphs.