Examples Of Lock Table - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

at the end of statement execution. When you issue a LOCK TABLE statement without turning
off AUTOCOMMIT, Neoview SQL locks the table temporarily, commits the transaction at the
end of the LOCK TABLE statement and releases the locks. If you use LOCK TABLE, turn off
AUTOCOMMIT by using the SET TRANSACTION statement. See
Option" (page
Indexes
LOCK TABLE attempts to lock all indexes of any table it locks. If an index is not available or if
the lock request times out, LOCK TABLE displays a warning and continues to request locks on
other indexes.

Examples of LOCK TABLE

Lock a table with an exclusive lock (at a time when few users need access to the database)
to perform a series of updates:
BEGIN WORK;
LOCK TABLE persnl.employee
IN EXCLUSIVE MODE;
//Obtains a table lock on the table persnl.employee
UPDATE persnl.employee
SET salary = salary * 1.05
WHERE jobcode <> 100;
//This IUD operation will automatically acquire row locks in addition
//to the table lock.
COMMIT WORK;
COMMIT WORK releases the row locks associated with the IUD operation and automatically
unlocks the table when it ends the transaction.
Delete all rows of the JOB table that have a job code that is not assigned to any employee:
BEGIN WORK;
--- SQL operation complete.
LOCK TABLE persnl.job
IN EXCLUSIVE MODE;
--- SQL operation complete.
LOCK TABLE persnl.employee
IN SHARE MODE;
--- SQL operation complete.
DELETE FROM persnl.job
WHERE jobcode NOT IN
(SELECT DISTINCT jobcode
FROM persnl.employee);
--- 1 row(s) deleted.
COMMIT WORK;
--- SQL operation complete.
150
SQL Statements
29).
"Effect of AUTOCOMMIT

Advertisement

Table of Contents
loading

Table of Contents