


The usual transaction concept (COMMIT, ROLLBACK) ensures that related modifications of several data objects are performed completely or not at all.
When DB procedures are called from an application, the user would like to have the same behavior as for SQL statements. If it is successful, the DB procedure should perform all the database actions. If it is not successful, it should not leave any effect in the database. This can only be realized with the help of subtransactions. A DB procedure must not contain any COMMIT or ROLLBACK because otherwise it would intervene unexpectedly in the transaction control of the application program. To be able to reset the effects of a DB procedure (and only these effects) if there is an error, the DB procedure must be formulated as a subtransaction. For this purpose, ADABAS provides the commands SUBTRANS BEGIN, SUBTRANS END and SUBTRANS ROLLBACK. If it is successful, a DB procedure is concluded with SUBTRANS END. If error situations arise which require a resetting of the DB procedure's effects, this can be achieved by means of SUBTRANS ROLLBACK without this influencing the top-level transaction control of the application program. Since DB procedures can be called in a nested way, the nesting of subtransactions within subtransactions is also supported.
Apart from the use of subtransactions for programming DB procedures and triggers, they are also necessary to program library functions containing SQL statements with a proper error handling; that is, without influencing the transaction control of the main program which invoked the library function.


