Using CitectSCADA > Exchanging Data with Other Applications > Using Structured Query Language > Using a transaction

Using a transaction

You can use a database transaction for more sophisticated database operations. A database transaction allows you to execute a series of SQL commands and then either commit the changes to the database, or 'roll back' (cancel) the changes, for example:

SQLBeginTran(hSQL); ! Begin the transaction
SQLExec(hSQL, "UPDATE recipe SET water = '12' WHERE NAME = 'Bread'");
SQLExec(hSQL, "UPDATE recipe SET milk = '1' WHERE NAME = 'Bread'");
IF . . . THEN
SQLCommit(hSQL); ! Commit the transaction
ELSE
SQLRollBack(hSQL);! Cancel the transaction
END

Check the ODBC-compatibility level of your database driver if you cannot use transactions.

See Also