Example: NOWAIT Option - Teradata Database - Teradata Vantage NewSQL Engine

SQL Data Manipulation Language

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Published
March 2019
Language
English (United States)
Last Update
2019-05-03
dita:mapPath
fbo1512081269404.ditamap
dita:ditavalPath
TD_DBS_16_20_Update1.ditaval
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata Vantage™

You have a request that you do not want to be placed in the lock queue if it cannot be serviced immediately. In this case, use the NOWAIT option. For example:

     LOCKING employee FOR READ NOWAIT
     SELECT employee_number,  last_name
     FROM employee
     WHERE department_number=401;

     *** Failure 7423 Object already locked and NOWAIT.
            Transaction Aborted. Statement# 1, Info =0

Another request had employee locked, so you must resubmit the request.

     LOCKING employee FOR READ NOWAIT
     SELECT employee_number, last_name
     FROM employee
     WHERE department_number=401;

      *** Query completed. 7 rows found. 2 columns returned.
      *** Total elapsed time was 1 second.
     employee_number  last_name
     ---------------  --------------------
                1003  Trader
                1004  Johnson
                1013  Phillips
                1002  Brown
                1010  Rogers
                1022  Machado
                1001  Hoover

This time, no locks were being held on employee, so the request completed successfully.