|
|
|
|
- Overview
- Starting a transaction
- Validating a transaction
- Canceling a transaction
- Resuming a transaction
- Example
Starting with version 21, you can manage transactions in SQL code. The following SQL statements can be used to start a transaction: - BEGIN
- BEGIN WORK
- BEGIN TRANSACTION
- START TRANSACTION
- START TRANSACTION ISOLATION <Level>. The <Level> parameter can correspond to:
- READ UNCOMMITTED
- READ COMMITTED
- REPEATABLE READ
- SERIALIZABLE
If no isolation level is defined in the SQL command, the isolation level that is currently defined will be used for the transaction.
To define the isolation level, you can also use the following syntax: SET ISOLATION <Level> The <Level> parameter can correspond to: - READ UNCOMMITTED
- READ COMMITTED
- REPEATABLE READ
- SERIALIZABLE
The following SQL syntaxes can be used to validate a transaction: - COMMIT
- COMMIT WORK
- COMMIT TRANSACTION
The syntaxes used to chain a new transaction are also available: - COMMIT AND CHAIN
- COMMIT WORK AND CHAIN
- COMMIT TRANSACTION AND CHAIN
The following SQL syntaxes can be used to cancel a transaction: - ROLLBACK
- ROLLBACK WORK
- ROLLBACK TRANSACTION
The syntaxes used to chain a new transaction are also available: - ROLLBACK AND CHAIN
- ROLLBACK WORK AND CHAIN
- ROLLBACK TRANSACTION AND CHAIN
You can use the following SQL syntax to set and name a savepoint in the current transaction: SAVEPOINT SavepointName You can use the following SQL syntax to roll back the operations performed within the transaction since the savepoint was established: ROLLBACK TO SAVEPOINT SavepointName let sdrTransactionStart is SQL Query = [ START TRANSACTION ]  let sdrSavePoint is SQL Query = [ SAVEPOINT MyPoint ]  let sdr is SQL Query = [ INSERT INTO Customer VALUES (3, 20), (4,22) ]  let sdrRollbackSavePoint is SQL Query = [ ROLLBACK TO SAVEPOINT MyPoint ]  let sdrTransactionEnd is SQL Query = [ COMMIT TRANSACTION ]  IF NOT HExecuteQuery(sdrTransactionStart) THEN Trace(HErrorInfo()) END  sdrSavePoint is Data Source  IF NOT HExecuteSQLQuery(sdrSavePoint, "SAVEPOINT MyPoint") THEN Trace(HErrorInfo()) END  IF NOT HExecuteQuery(sdr) THEN Trace(HErrorInfo()) END  sdrRollbackSavePoint is Data Source IF NOT HExecuteSQLQuery(sdrRollbackSavePoint, "ROLLBACK TO SAVEPOINT MyPoint") THEN Trace(HErrorInfo()) END  let sdr2 is SQL Query = [ INSERT INTO Customer VALUES (10, 120), (11,122) ]  IF NOT HExecuteQuery(sdr2) THEN Trace(HErrorInfo()) END  IF NOT HExecuteQuery(sdrTransactionEnd) THEN Trace(HErrorInfo()) END
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|