Previous Page | Next Page

SAS Component Language Dictionary

UNLOCK



Releases a lock on the current row
Category: SAS Table

Syntax
Details
Example
See Also

Syntax

sysrc=UNLOCK(table-id);

sysrc

contains the return code for the operation:

0

successful

[ne]0

not successful

Type: Numeric

table-id

is the identifier that was assigned when the table was opened. If table-id is invalid, the program halts.

Type: Numeric


Details

A table that is opened in UPDATE mode receives RECORD-level locking by default. Whenever an application reads a row from a table that was opened in UPDATE mode, it attempts to obtain a lock on the row. All of the following functions lock a row when the table is opened in UPDATE mode:

DATALISTC DATALISTN FETCH FETCHOBS LOCATEC LOCATEN

Row locks are implicitly released when a different row is read. However, when a user is finished with a row but has not read another row, you can use UNLOCK to explicitly release a lock on the row.

This function is useful when rows from a secondary SAS table are read to obtain values.

Note:   UNLOCK is not directly related to the LOCK function, which locks SAS catalogs, catalog members, and SAS tables. However, if the table in question is accessed through SAS/SHARE software using the REMOTE engine, then UNLOCK can be used to enable other applications to access individual rows. See SAS Language Reference: Dictionary for more information.  [cautionend]


Example

Call FETCH to read a new row from the SAS table MYDATA, which is opened in UPDATE mode. After data from the row is processed, call UNLOCK to release the lock on the row.

dsid=open('mydata','u');
rc=fetch(dsid);
    ...more SCL statements...
rc=unlock(dsid);


See Also

CLOSE

DATALISTC and DATALISTN

FETCH

FETCHOBS

LOCATEC and LOCATEN

OPEN

Previous Page | Next Page | Top of Page