TODBCBeginTrans
(Engine-Level Function)
Description: | Indicates to an ODBC-compliant database that a transaction is to be started. TODBCBeginTrans is similar to ODBCBeginTrans, except that it runs in its own thread (see the Comments section for differences). |
Returns: | Nothing (see parameters) |
Usage: | Script Only. |
Function Groups: | Database and Data Source, ODBC |
Threaded: | Yes |
Related to: | ODBCBeginTrans | ODBCCommit | ODBCRollback | TODBCCommit | TODBCRollback |
Format: | TODBCBeginTrans(DB[, ErrorMsg, SQLState, ErrorCode]) |
Parameters: |
DB |
Required. A n 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 variable that will contain the native error code for the given driver and an error condition for the last error that occurred. |
Comments: | TODBCBeginTrans indicates that a transaction is to be started on the specified ODBC database. The statement executes in its own thread, and completion is indicated by the ErrorCode parameter being set to a valid value, or to "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; ]