function
Library: Database access (OMDB legacy)
Include: omdb.xin |
define external dbSetTransactionType value dbDatabase database to value integer mode
Argument definitions
Use dbSetTransactionType to set the mode of a database connection to either auto-commit or manual-commit.
You must include the following line at the beginning of your OmniMark program:
include "omdb.xin"
The dbDatabase object database must be:
The value for mode may be either
The default mode is auto-commit. In this mode, every insert, delete, or update operation is a permanent change to the database. In manual-commit mode, however, these operations are not permanent until they are committed using dbCommit. In manual-commit mode, operations can be rolled back (canceled) with dbRollback.
The following example shows a simple transaction comprising two database insertions:
include "omdb.xin" process ; local variables local dbDatabase this-db local dbTable course local dbTable schedule local stream course-data variable initial { '504' with key 'cid', 'What is that Sound?' with key 'CourseName' } local stream schedule-data variable initial { '504' with key 'cid', '2000/03/21' with key 'CourseDate' } ; create the database OMX objects set this-db to dbOpenODBC 'dbDemo' set course to dbTableOpen this-db table 'Course' set schedule to dbTableOpen this-db table 'Schedule' ; start a transaction dbSetTransactionType this-db to DB_MANUAL_COMMIT ; add records to the two tables dbTableInsert course from course-data dbTableInsert schedule from schedule-data ; commit the transaction dbCommit this-db ; catch the database exceptions catch #external-exception identity catch-id message catch-msg output 'An error occurred while accessing an omDB function.%n' output '%g(catch-id) : %g(catch-msg)%n' ; if the transaction was not finished, ; we must roll it back in the catch dbRollback this-db