Library: Database access (OMDB)
Import : omdb.xmd

define external db.set-transaction-type
    of value db.database database
    to value integer    mode

Argument definitions

is a db.database object obtained by opening a connection to a database using one of the db.open functions.
is the desired transaction mode, either db.auto-commit or db.manual-commit.


Use db.set-transaction-type to set the mode of a database connection to either auto-commit or manual-commit.


The db.database object database must be:

The value for mode may be either

Usage Notes

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 db.commit. In manual-commit mode, operations can be rolled back (canceled) with db.rollback.


The following example shows a simple transaction comprising two database insertions:

  import "omdb.xmd" prefixed by db.
     local db.database this-db
     local db.table course
     local db.table 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 db.open-odbc 'dbDemo'
     set course to db.open-table in this-db table 'Course'
     set schedule to db.open-table in this-db named 'Schedule'
     ; start a transaction
     db.set-transaction-type of this-db to db.manual-commit
     ; add records to the two tables
     db.insert into course from course-data
     db.insert into schedule from schedule-data
     ; commit the transaction
     db.commit 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
         db.rollback this-db