|
||||||||||
|
||||||||||
Other Library Functions |
function | dbSetTransactionType |
Library: omdbext - extended high level database support
Include: omdbext.xin |
dbSetTransactionType value dbDatabase database to (DB_AUTO_COMMIT | DB_MANUAL_COMMIT)
The dbSetTransactionType function sets the mode of a database connection to either auto-commit or manual-commit.
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 "omdbext.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 setTransactionType 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
Other Library Functions dbCommit dbProcedureClose dbProcedureExecute dbProcedureOpen dbRollback dbSetTransactionType dbStatementCompile dbStatementDiscard dbStatementExecute |
---- |