Example: NOWAIT Option - Analytics Database - Teradata Vantage

SQL Data Manipulation Language

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-04-02
dita:mapPath
pon1628111750298.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
esx1472246586715
lifecycle
latest
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. Use the NOWAIT option. For example:

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

Result:

     *** 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;

Result:

      *** 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.