PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • How to lock a table or the query records?
  • Native ORACLE Access
  • Native MySQL Access
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
SQLLock (Function)
In French: SQLBloque
Native AccessesAvailable only with this kind of connection
Used to lock:
  • The entire data table, in read and write mode. This data cannot be accessed by the other computers.
  • The records selected by the query. This data cannot be accessed by the other computers. This method can be used to update records for example. The query result is not returned.
SQLLock can be used on all Native Accesses (except SQLite and XML) and on some OLE DB providers (according to the capacities of provider and database). This function has no effect for the tables accessed by ODBC drivers.
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.
Example
Qry is string
// Start of transaction for lock
SQLTransaction(sqlStart)
// Locks the entire table
SQLLock("CUSTOMER", "Table")
// Runs the query
Qry = "UPDATE CUSTOMER SET CUSTOMERNAME = 'DOE' WHERE CUSTOMERREF = 1043"
SQLExec(Qry, "QRY1")
// Unlock the file
SQLTransaction(sqlCommit)
QryLock, QryUpdate are strings
// Start of transaction for lock
SQLTransaction(sqlStart)
// Definition of Query
QryLock = "SELECT * FROM CUSTOMER WHERE CUSTOMERREF = 1043"
// Lock the result of SELECT query
SQLLock(QryLock)
// Define an update query
QryUpdate = "UPDATE CUSTOMER SET CUSTOMERNAME = 'DOE' WHERE CUSTOMERREF = 1043"
// Run an update query
SQLExec(QryUpdate, "QRY1")
// Unlock the records
SQLTransaction(sqlCommit)
Syntax

Locking an entire data table Hide the details

<Result> = SQLLock(<Table Name> , <"Table">)
<Result>: Boolean
  • True if the lock was performed,
  • False otherwise.
<Table Name>: Character string (with or without quotes)
Name of data table to lock.
<"Table">: Character string (with quotes)
"Table": Character string used to lock a data table in its entirety.

Locking the records selected by a query Hide the details

<Result> = SQLLock(<Query Text>)
<Result>: Boolean
  • True if the lock was performed,
  • False otherwise.
<Query Text>: Character string (with quotes)
Text of query used to select the records to lock.
Remarks

How to lock a table or the query records?

To lock a table (or the query records):
  1. Start a transaction (SQLTransaction associated with the sqlStart constant).
  2. Lock the records (SQLLock).
    Caution: if you lock the query records, the query is run but the result is not returned.
  3. Unlock the records by ending the transaction (SQLTransaction associated with the sqlEnd constant).
WINDEVWEBDEV - Server codeNative Accesses

Native ORACLE Access

You have the ability to configure the behavior of SQLLock when the record is locked (infinite wait, immediate lock report, ...). This setting is performed in the options of WDORAINS.
WINDEVWEBDEV - Server codeNative Accesses

Native MySQL Access

SQLLock and SQLTransaction are used to manage the locks and transactions on the MySQL tables of "innoDB" type.
Components
WINDEVWEBDEV - Server codeReports and Queries wd230hf.dll
Linux wd230hf.so
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment