swirl
Guide to OmniMark 7   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Syntax   Related Concepts   Other Library Functions  
function  

db.set-transaction-type

 
 

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

Declaration

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

Argument definitions

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


Purpose

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

Requirements

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

Example

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

  import "omdb.xmd" prefixed by db.
  process
     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

    Related Syntax
   db.execute-in
   db.database
   db.insert
   db.update
   db.delete
   db.table
   db.commit
   db.rollback
   dbStatementExecute
 
Related Concepts
   Using the OMDB library
 
Other Library Functions
   db.advance-recordset
   db.close
   db.commit
   db.compile-statement
   db.database
   db.delete
   db.discard
   db.execute
   db.execute-in
   db.field
   db.insert
   db.move-record
   db.omdb-version
   db.omdb-version-oci8
   db.omdb-version-oci8i
   db.omdb-version-odbc
   db.open-oci8
   db.open-oci8i
   db.open-odbc
   db.open-procedure
   db.open-table
   db.prepare
   db.procedure
   db.query
   db.reader
   db.record-exists
   db.rollback
   db.set-transaction-type
   db.statement
   db.streaming-execute
   db.table
   db.update
   db.writer
 
 

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ LEGACYLIBRARIES ] [ ERRORS ]

OmniMark 7.1.2 Documentation Generated: June 28, 2005 at 5:45:04 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © Stilo Corporation, 1988-2005.