When AutoCommit = false and multiple
Update() calls are executed within the same transaction,
error handling differs significantly:
-
Traditional C/S (partial success) -- If one update fails, only the failed operation is rolled back. Preceding updates are committed successfully within the transaction.
-
PowerServer (atomic rollback) -- If an update fails, preceding successful updates in the same transaction may also be rolled back to maintain data consistency.
-
Best practice -- Developers should check the execution result of each update operation and decide whether to commit or rollback to ensure consistent behavior across both C/S and cloud environments.
In the following example, three
DataWindowobjects (dw_1,dw_2, anddw_3) executeUpdate()operations within the same transaction.Traditional C/S: If the update of
dw_2fails, only that operation is rolled back. The updates ofdw_1anddw_3are committed successfully.PowerServer: If the update of
dw_2fails, both the failed operation and any preceding successful updates within the same transaction (such asdw_1) are rolled back. Subsequent operations (such asdw_3) are executed in a new transaction and may be committed independently.SQLCA.Autocommit = false; dw_1.update() //Assuming update is successful dw_2.update() //Assuming update failed dw_3.update() //Assuming update is successful Commit using SQLCA;
The code can be revised as follows, to check the return status after each
Update()call and explicitly executeCOMMITorROLLBACK.SQLCA.Autocommit = false; If dw_1.update() = 1 then Commit using SQLCA; Else Rollback using SQLCA; End if If dw_2.update() = 1 then Commit using SQLCA; Else Rollback using SQLCA; End if If dw_3.update() = 1 then Commit using SQLCA; Else Rollback using SQLCA; End if


