ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / Managing databases / SQL functions
  • How to lock a table or the query records?
  • Native ORACLE Access
  • Native MySQL Access
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
SQLLock (Function)
In french: SQLBloque
Native Connectors (Native Accesses)Available 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.
Example
Req is string
// Début de transaction pour bloquer
SQLTransaction(sqlStart)
// Bloque toute la table
SQLLock("CLIENT", "Table")
// Exécute la requête
Req = "UPDATE CLIENT SET NOMCLIENT = 'DUPOND' WHERE REFCLIENT = 1043"
SQLExec(Req, "REQ1")
// Débloquer le fichier
SQLTransaction(sqlCommit)
ReqBloque, ReqUpdate are strings
// Début de transaction pour bloquer
SQLTransaction(sqlStart)
// Définition de Requête
ReqBloque = "SELECT * FROM CLIENT WHERE REFCLIENT = 1043"
// Bloquer le résultat de la requête SELECT
SQLLock(ReqBloque)
// Définition d'une requête de mise à jour
ReqUpdate = "UPDATE CLIENT SET NOMCLIENT = 'DUPOND' WHERE REFCLIENT = 1043"
// Exécution d'une requête de mise à jour
SQLExec(ReqUpdate, "REQ1")
// Débloquer les enregistrements
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
Name of data table to lock.
<"Table">: Character string
"Table": Character string used to block an entire data table..

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
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).
    Warning: if you block the records of a query, the query is executed but the result is not returned.
  3. Unlock the records by ending the transaction (SQLTransaction associated with the sqlEnd constant).
WINDEVWEBDEV - Server codeNative Connectors (Native 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 Connectors (Native Accesses)

Native MySQL Access

SQLLock and SQLTransaction are used to manage locks and transactions only on "InnoDB" tables.
Component: wd300hf.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/27/2025

Send a report | Local help