Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The programming example below (TESTTRANS) demonstrates transaction processing.  The The purpose is to write (and/or delete) 10 rows, with record IDs from 90 to 99, in the CUSTOMERS table.   (You can use the CUSTOMERS table in the EXAMPLES application, if you wish.)  Before Before each row is written, it is locked.  Only if each row is successfully locked, written, and unlocked will all the rows be committed to the database.  If If the FAIL argument is passed with a value of 1, row 96 is locked before the loop writing the 10 rows, causing the write to row 96 to fail.   This This will cause the entire transaction to be rolled back, so that none of the 10 rows is written to the database, thus returning the database to its condition before the transaction started.

...

Create the TESTTRANS stored procedure by pasting the code below.  See See the comments for how to run this stored procedure.

...