Using the wait/nowait options of the lock table command

Use the wait option in the lock table command to specify the length of time the command waits to acquire a table lock. For example, the following command, inside a transaction, sets a wait period of 2 seconds for acquiring a table lock on the titles table:

lock table titles in share mode wait 2

If the wait time expires before a table lock is acquired, the transaction proceeds, and row or page locking is used, exactly as it would have been without the lock table command. The following informational message (error number 12207) is generated:

Could not acquire a lock within the specified wait period. COMMAND level wait...

For an example of error handling during transactions, see lock table in the Reference Manual.

NoteIf you use lock table...wait without specifying no_of_seconds, the command waits indefinitely for a lock.

You can set time limits on waiting for a lock at the session level and the system level. The wait period set with the lock table command overrides both of these, as described in the following section.

The nowait option is equivalent to the wait option with a 0-second wait: lock table either obtains a table lock immediately or generates the informational message given above. If the lock is not acquired, the transaction proceeds as it would have without lock table.