TODBCCommit

(Engine-Level Function)

Description: Indicates to an ODBC-compliant database that a transaction is to be committed. TODBCCommit is similar to ODBCCommit, except that it runs in its own thread (see the Comments section for differences).
Returns: Nothing
Usage: Script Only.
Function Groups: Database and Data Source,  ODBC
Threaded: Yes
Related to: ODBCBeginTrans | ODBCCommit | ODBCRollback | TODBCBeginTrans | TODBCRollback
Format:  TODBCCommit(DB [, ErrorMsg, SQLState, ErrorCode])
Parameters:  
DB
Required. An ODBC value for the specified ODBC database as returned by ODBCConnect.
ErrorMsg
A parameter that will contain the last error message returned by the function.
SQLState
A parameter that will return the SQL state that the statement was in when the last error occurred.
ErrorCode
A parameter that is a variable that will contain the native error code for the given driver and an error condition for the last error that occurred.
Comments: Commits a transaction defined as all the SQL statements since the transaction began. The statement executes in its own thread, and completion is indicated by the ErrorCode parameter being set to a valid value, or "0" in the case of no errors.
If any error, no matter how minor, occurs as a result of the statement, and the TODBCConnect or ODBCConnect that connected to the database had its Disconnect parameter set to true, the value of DB will become invalid (i.e. the connection to the database will be dropped).

Example:

StartBegin [
  If Condition WaitBegin;
  [
    TODBCBeginTrans(DB, Invalid, Invalid, ErrCode);
  ]
]
WaitBegin [
  If ErrCode WaitWork;
  [
    { Check Error code }
    …
    ErrCode = Invalid;
    { Do some transaction work }
    …
  ]
]
WaitWork [
  If ErrCode WaitCommit;
  [
    ErrCode = Invalid;
    TODBCCommit(DB, Invalid, Invalid, ErrCode);
  ]
]
WaitCommit [
  If ErrCode Done;
]