TODBCRollback

(Engine-Level Function)

Description: Indicates to an ODBC-compliant database that a transaction is to be discarded. TODBCRollback is similar to ODBCRollback, 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 | TODBCCommit
Format: TODBCRollback(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 variable that will contain the native error code for the given driver and an error condition for the last error that occurred.
Comments: Discards a transaction defined as all the SQL statements executed on a database since the transaction began.
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 WaitEnd;
  [
    { Check error code, rollback if bad }
    IfElse(ErrCode != 0, Execute(
      ErrCode = Invalid;
      TODBCRollback(DB, Invalid, Invalid, ErrCode);
    );
    { Else } Execute(
      ErrCode = Invalid;
      TODBCCommit(DB, Invalid, Invalid, ErrCode);
    ));
  ]
]
WaitEnd [
If ErrCode Done;
]