BEGINTRANS( )
Begins transaction logging.
Syntax
BEGINTRANS([<database name expC> [,<isolation level expN>]])
<database name expC>
The BDE alias of the SQL database in which to begin the transaction.
If <database name expC> is omitted but a SET DATABASE statement has been issued, BEGINTRANS( ) refers to the database in the SET DATABASE statement.
If <database name expC> is omitted and no SET DATABASE statement has been issued, the default database, which supports DBF and DB tables is used.
<isolation level expN>
Specifies a pre-defined server-level transaction isolation scheme.
Valid values for <isolation level> are:
Value |
Description |
0 |
Server's default isolation level |
1 |
Uncommitted changes read (dirty read) |
2 |
Committed changes read (read committed) |
3 |
Full read repeatability (repeatable read) |
<isolation level> is not supported for DBF and DB tables.
If an invalid value is given for <isolation level>, a "Value out of range" error is generated.
The <isolation level> is server-specific; a "Not supported" error will result from the database engine if an unsupported level is specified.
Note
If you include <database name expC> when you issue BEGINTRANS( ), you must also include it in subsequent COMMIT( ) or ROLLBACK( ) statements within that transaction. If you don't, dBASE Plus. ignores the COMMIT( ) or ROLLBACK( ) statement.
Description
Separate changes that must be applied together are considered to be a transaction. For example, transferring money from one account to another means debiting one account and crediting another. If for whatever reason one of those two changes cannot be done, the whole transaction is considered a failure and any change that was made must be undone.
Transaction logging records all the changes made to all the tables in a database. If no errors are encountered while making the individual changes in the transaction, the transaction log is cleared with COMMIT( ) and the transaction is done. If an error is encountered, all changes made so far are undone by calling ROLLBACK( ).
All locks made during a transaction are maintained until the transaction is completed. This ensures that no one else can make any changes until the transaction is committed or abandoned.
You can't nest transactions with BEGINTRANS( ). If you issue BEGINTRANS( ) against an SQL database that does not support transactions, or if a server error occurs, BEGINTRANS( ) returns false. Otherwise, it returns true. If BEGINTRANS( ) returns false, use SQLERROR( ) or SQLMESSAGE( ) to determine the nature of the server error that might have occurred.
OODML
Call the beginTrans( ) method of the Database object.