WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Stored procedures
Locks a record and restricts the access to this record for all the other applications. Then, the record can be unlocked by <Source>.UnlockRecNum.
Remark: Several cases may occur after the call to <Source>.LockRecNum:
  • The record is already locked by another application: the lock cannot be performed.
  • The data file containing the record is entirely locked: the lock cannot be performed.
An automatic management of lock errors and modification conflicts is performed by default (except in the code of stored procedures). This assisted management of errors can be customized or disabled at any time by <Source>.OnError.
HErrorLock returns True if a lock problem occurs.
Caution: <Source>.LockRecNum must be used with great care: when locked, the record is not read again. Therefore, it may have been deleted or modified since the last access to this record. It is recommended to use <Source>.Read with a lock option.
Java This function is available for HFSQL data files only. It is not available for the data files accessed by JDBC.
// Lock a record in the Customer data file
Customer.LockRecNum(hRecNumCurrent, hLockReadWrite)
// Process on the record
// Restore access to the record
<Result> = <Source>.LockRecNum([<Record to lock>] [, <Lock>])
<Result>: Boolean
  • True if the operation was performed,
  • False if a problem occurs. HError is used to identify the error.
<Source>: Type corresponding to the specified source
Name of the data file used.
<Record to lock>: Optional integer
Number of the record to lock.
If this parameter is not specified, <Source>.LockRecNum will handle the current record.
Native Connectors (Native Accesses) <Source>.LockRecNum locks the current record only. You cannot specify a record number other than the current one (to specify the current record number, use the hRecNumCurrent constant).
<Lock>: Optional integer constant
Used to define the type of lock set on the record.
hLockNoNo lock: the record can be read or modified by another application.
hLockReadWriteLock in read/write: the record in the data file cannot be read or modified by another application.
The other application will not be able to lock the record or the data file.
(default value)
Lock in write mode: the record in the data file can be read, but cannot be modified by another application.
The other application will not be able to lock the record or the data file.

Modifying the type of lock for a record

To modify the type of record lock, call <Source>.LockRecNum and specify the requested type of lock. There is no need to unlock the record beforehand.

Effect of lock mode

If the data file lock mode is set to hModeMono (see <Source>.Mode), <Source>.LockRecNum has no effect.

Lock failure

If the record is already locked, the lock request is retried HNbRetry times (50 by default).
If the data file cannot be locked after H.NbRetry attempts, HErrorLock returns True. The H.Level variable indicates whether the record or the data file is locked.

Number of locks

The number of records that can be individually locked in a data file is unlimited.
WINDEVWEBDEV - Server codeReports and QueriesAjaxStored proceduresNative Connectors (Native Accesses)

Native SQL Server Connector: Lock in write mode

<Source>.LockRecNum locks the record in write mode, not in read-only. Therefore, <Source>.LockRecNum prevents the record from being modified by another computer.
<Source>.LockRecNum used on a locked record does NOT return a lock error (because only a read operation is performed).
However, <Source>.Modify will return a lock error on the locked record.
WINDEVWEBDEV - Server codeReports and QueriesAjaxStored proceduresOLE DB

Managing locks in OLE DB

<Source>.LockRecNum is not supported. This function generates the non-fatal error "Invalid operation for this type of database".
WINDEVWEBDEV - Server codeAjaxNative Connectors (Native Accesses)

Persistence of lock

With the Native SQLServer and Sybase Connectors, re-reading a record that was locked by <Source>.LockRecNum unlocks the record.
Component: wd280hf.dll
Minimum version required
  • Version 25
This page is also available for…
Click [Add] to post a comment