READVU Statement

The READVU statement performs a READV, simultaneously setting a lock on the item from which the attribute is to be read.

Format

READVU var FROM [filevar,] item-ID, attr#  [LOCKED

   statements

END] [THEN statements1] [ELSE statements2]

Parameter(s)

LOCKED statements

Executes statements if the item was already locked by another process. The statements of the LOCKED clause follow the syntax of statements in THEN or ELSE clauses.

Description

The behavior of the READVU statement is identical to that of the READV statement, except that a lock is placed on the file item to be read.

See READV Statement for more information on the syntax of READVU. When a file item is locked, it cannot be read by another READU, READVU, or MATREADU statement until the lock is removed. The lock is removed by exiting the program, updating the file with the WRITE, WRITEV, MATWRITE, or DELETE statements, or releasing the lock with the RELEASE statement or RESET-ITEM-LOCKS command. The file can be updated without removing the item lock with the WRITEU, WRITEVU, or MATWRITEU statements. There is no limit to the number of items that can be locked simultaneously at a given time.

If the READVU statement is executed on an item already locked by another user, the program hangs until the lock is released, unless the LOCKED clause is specified. The LOCKED clause allows the user to exit from the READVU statement without waiting for the item to be released. If the LOCKED clause is used, the dynamic array variable var is not assigned.

If the file item does not exist, the item lock is still set, and the ELSE clause is executed. Thus the READVU statement may be used to reserve an item for use by the program even if it did not previously exist.

Example

In this application, the file CUSTOMERS is read and locked by READVU.

OPEN "CUSTOMERS" TO CUSTFILE ELSE  

   ABORT 201, "CUSTOMERS"   

END  

PRINT "ENTER CUSTOMER ID: ":    

INPUT ID   

FOUND = 0

READVU PHONE FROM CUSTFILE,ID,6 FOUND

   PRINT "ITEM IS FOUND."

   FOUND = 1

END ELSE  

   PRINT "ERROR!"    

   STOP  

END

 

See Also

Statement and Function Reference