SQL/MP Reference Manual

HP NonStop SQL/MP Reference Manual523352-013
U-2
Examples—UNLOCK TABLE
When you specify the default value, TABLELOCK ENABLE, the executor can
determine at run time whether a table lock is necessary. This strategy increases
concurrency for statements that do not require a table lock, such as those
statements that need only a few row locks.
A host program cannot execute an UNLOCK TABLE statement if the program has
a cursor open on the table or view with STABLE or REPEATABLE access. Close
the cursor with a CLOSE or FREE RESOURCES statement before you execute
UNLOCK TABLE statement.
Examples—UNLOCK TABLE
This example locks and unlocks a nonaudited table from an SQLCI session in
which the AUTOWORK AUDITONLY is ON:
>> VOLUME $VOL1.PERSNL;
>> LOCK TABLE JOB IN EXCLUSIVE MODE;
--- SQL operation complete
>> DELETE FROM JOB WHERE JOBCODE
+> NOT IN (SELECT DISTINCT JOBCODE FROM EMPLOYEE);
--- 8 row(s) deleted.
...
>> UNLOCK TABLE JOB;
--- SQL operation complete
This example locks and unlocks a nonaudited table from a program:
EXEC SQL
LOCK TABLE SALES.PARTS IN EXCLUSIVE MODE;
EXEC SQL
CONTROL TABLE SALES.PARTS TABLELOCK ON;
...
EXEC SQL
UNLOCK TABLE SALES.PARTS;
EXEC SQL
CONTROL TABLE SALES.PARTS TABLELOCK ENABLE;