ODBCBeginTrans

Description:              This statement indicates to a specified ODBC-compliant database that a transaction is to be started.

Returns:                    Nothing (return values in parameters)

Usage:                       Script

Format:                      ODBCBeginTrans(DB [, ErrorMsg, SQLState, ErrorCode])

Parameters:             DB    { ODBC database }  { required }  { no default }

                                      An ODBC-compliant database as returned by ODBCConnect.

                                    ErrorMsg    { text (return value) }  { optional }  { no default }

                                      An optional parameter that will contain the last error message returned by the function.

                                    SQLState    { numeric (return value) }  { optional }  { no default }

                                      An optional parameter that will return the SQL state that the statement was in when the last error occurred.

                                    ErrorCode    { numeric (return value) }  { optional }  { no default }

                                      An optional 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:               A transaction is a unit of work that is done as a single, atomic operation; that is, the operation succeeds or fails as a whole. ODBCBeginTrans indicates that a transaction is to be started on the specified ODBC database. Note that each ODBC database driver may implement different levels of transaction support (or none at all), and the documentation for that driver should be consulted to determine the level of transaction support. The transaction should be terminated either with an ODBCCommit or an ODBCRollback.

                             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:

[

  ODBCBeginTrans(DB); 

  ODBC(DB, "DELETE * FROM TEST"); 

  ODBC(DB, "INSERT INTO TEST VALUES('KeyString', 'Value')"); 

  ODBCCommit(DB); 

]

See Also:

ODBCCommit | ODBCRollback | TODBCBeginTrans | TODBCCommit | TODBCRollback