PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US

  • Modifying the type of lock for a record
  • Effect of lock mode
  • Lock failure
  • Number of locks
  • Native SQL Server Access: Lock in write mode
  • Managing locks in OLE DB
  • Persistence of lock
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Locks a record and restricts the access to this record for all the other applications. Then, the record can be unlocked by HUnlockRecNum.
Note: Several cases may occur after the call to HLockRecNum:
  • 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 HOnError.
HErrorLock returns True if a lock problem occurs.
Caution: HLockRecNum must be used with great care: indeed, during the lock, the record is not re-read. Therefore, it may have been deleted or modified since the last access to this record. We recommend that you use HRead with lock option.
Windows Mobile This function can be used with HFSQL Client/Server data files or with data files handled by Native Accesses. This function is not available for HFSQL Mobile.
Versions 16 and later
Java This function is now available for the Java applications.
Java This function is available for the HFSQL data files only. It is not available for the data files accessed by JDBC.
New in version 16
Java This function is now available for the Java applications.
Java This function is available for the HFSQL data files only. It is not available for the data files accessed by JDBC.
Java This function is now available for the Java applications.
Java This function is available for the HFSQL data files only. It is not available for the data files accessed by JDBC.
Versions 17 and later
iPhone/iPad This function is now available for the iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for the iPhone/iPad applications.
iPhone/iPad This function is now available for the iPhone/iPad applications.
Versions 18 and later
Android Widget This function is now available in Android Widget mode.
Android This function is now available for the Android applications (for the HFSQL data files).
Universal Windows 10 App This function is now available in Windows Store apps mode.
New in version 18
Android Widget This function is now available in Android Widget mode.
Android This function is now available for the Android applications (for the HFSQL data files).
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
Android This function is now available for the Android applications (for the HFSQL data files).
Universal Windows 10 App This function is now available in Windows Store apps mode.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Note: From version 19, HFSQL is the new name of HyperFileSQL.
Example
// Lock a record found in CUSTOMER file
HLockRecNum(CUSTOMER, hCurrentRecNum, hLockReadWrite)
// Process on the record
...
// Give the access back to the record
HUnlockRecNum()
Syntax
<Result> = HLockRecNum([<File Name> [, <Record Number>]] [, <Lock>])
<Result>: Boolean
  • True if the operation was performed,
  • False if a problem occurred. HError is used to identify the error.
<File Name>: Optional character string (with or without quotes)
Name of data file used. If this name is not specified, HLockRecNum handles the last data file used by the last function for HFSQL management (starting with the letter H).
<Record Number>: Optional integer
Number of the record to lock. If this parameter is not specified, HLockRecNum handles the current record.
Native Accesses HLockRecNum locks the current record only. You cannot specify a record number other than the current one (to specify the current record number, use the hCurrentRecNum constant).
<Lock>: Optional integer constant
Used to define the type of lock performed on the record.
hLockWrite
(default value)
Lock in write mode: the record found in the data file can be read by another application but it cannot be modified by another application.
No lock on the record or on the data file can be defined by another application.
hLockReadWriteLock in read/write: the record found in the data file cannot be read or modified by another application.
No lock on the record or on the data file can be defined by another application.
hLockNoNo lock: the record can be read or modified by another application.
Remarks

Modifying the type of lock for a record

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

Effect of lock mode

HLockRecNum has no effect if the lock mode of data file is set to hModeMono (see HMode).

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 Accesses

Native SQL Server Access: Lock in write mode

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

Managing locks in OLE DB

HLockRecNum is not supported. This function generates the non-fatal error "Invalid operation for this type of database".
WINDEVWEBDEV - Server codeAjaxNative Accesses

Persistence of lock

With Native SQLServer and Sybase Accesses, re-reading a record locked by HLockRecNum unlocks this one.
Components
WINDEVWEBDEV - Server codeReports and Queries wd230hf.dll
Windows Mobile wp230hf.dll
Java wd230java.jar
Linux wd230hf.so
Android wd230android.jar
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment