Description

Provides a method for coordinating access to tables, rows, or columns by setting locks

Syntax

Lock(tablename, key, columnlist, locktype)

Parameters

The Lock routine has the following parameters.

ParameterDescription
TablenameSpecifies the name of the table to lock.
KeyKey of the row to lock. If null, the entire table is locked.
columnListAn @fm delimited list of columns to lock. If the columnList is null the entire record is locked.
Locktype

Set one of four lock types:

locktypeDescription
0Exclusive lock.
1Shared lock.
2Exclusive coordinated lock (row and column locks only).
3Shared coordinated lock (row and column locks only).

Remarks

Since the Lock routine uses the Lock statement, it is more efficient to use the Lock statement in a BASIC+ script.

Examples

/* Lock and unlock specific columns within a row */
declare subroutine lock, unlock
table = 'PRODUCTS'
row = '3542-5-310-1'
cols = 'DESCRIPTION':@fm:'PRICE'
locktype = ""
Lock(table,row,cols,locktype)
status = Get_Status(errCodes)
If status Then
   FSMsg(errCodes)
End
* Do Some Processing
call Unlock(table,row,cols,locktype)
status = Get_Status(errCodes)
If status Then
   FSMsg(errCodes)
End
/* Lock and unlock a row */
declare subroutine lock, unlock
table = 'PRODUCTS'
row = '3542-5-310-1'
cols = ''
locktype = ""
Lock(table,row,cols,locktype)
status = Get_Status(errCodes)
If status Then
   FSMsg(errCodes)
End
* Do Some Processing
Unlock(table,row,cols,locktype)
status = Get_Status(errCodes)
If status Then
   FSMsg(errCodes)
End
  • No labels