TABLE LOCK - IN EXCLUSIVE MODE
Posted in 2005
Topics: Stored Procedures & SPL, Transactions, Locking & Isolation
<html><div style='background-color:'><DIV class=RTE>Hi there, </DIV>There is a program that use LOCK TABLE table_name IN EXCLUSIVE MODE. Here is partial of code in the program; <DIV></DIV> <DIV></DIV> SELECT field_1, field_2, field_3, ...... <DIV></DIV> FROM table_name <DIV></DIV> WHERE field_1 IS NULL AND <DIV></DIV> field_2 IS NULL AND <DIV></DIV> field_3 IS NULL AND <DIV></DIV> field_4 IS NULL &nbs p; <DIV></DIV> <P> INTO TEMP <STRONG>tmp_table_name </STRONG>WITH NO LOG </P> <P> </P> <DIV></DIV> <DIV></DIV> .................... then later in the code .......................... <DIV></DIV> <DIV></DIV>BEGIN WORK {* 7550 *} <DIV></DIV><STRONG>LOCK TABLE tmp_table_name IN EXCLUSIVE MODE </STRONG> <DIV></DIV>WHENEVER ERROR CONTINUE <DIV></DIV> <DIV></DIV> ................................................................................ <DIV></DIV> <DIV></DIV> LET rec_cnt = rec_cnt + 1 & nbsp; <DIV></DIV> IF NOT rec_cnt MOD 100 THEN &nbs p; <DIV></DIV> DISPLAY rec_cnt, " Processed" AT 5,5 <DIV></DIV> COMMIT WORK &nbs p; <DIV></DIV> BEGIN WORK {* 7550 *} <DIV></DIV> <STRONG>LOCK TABLE tmp_table_name IN EXCLUSIVE MODE </STRONG> <DIV></DIV> END IF <DIV></DIV> <DIV></DIV> <DIV></DIV> <P> ................................................................................ ...... </P> <P>This program is running sometimes a huge batch of records (200,000+ rows). Yes, there is nite cron job also but eventually it needs to run during a day also.</P> <DIV></DIV> <DIV></DIV> <DIV></DIV>My question is <STRONG><U>how do avoid the LOCK - IN EXCLUSIVE MODE? </U></STRONG> <DIV></DIV> <P>Because every time when someone is running this program, another CANNOT run this program or any other programs that access the same table at all. It issued some source of error that indicated TABLE LOCK ( such as -144 ). Is there a better method or procedure that handle multi-users running LOCK TABLE applications?</P> <P>T Davis</P> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> &nb sp; </div></html>
Tah Davis said: > > <html><div style='background-color:'><DIV class=RTE></P> > <P>T Davis</P> > <DIV></DIV> > <DIV></DIV> > <DIV></DIV> > <DIV></DIV> </div></html> Once more, with feeling, please! -- Bye now, Obnoxio "C'est pas parce qu'on n'a rien à dire qu'il faut fermer sa gueule" - Coluche A smile is a gift that is free to the giver and precious to the recipient. But giving someone the finger is free too, and I find it more personal and sincere.