21.10.2013 Views

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Tip<br />

Transaction control statements<br />

If you expect the volume of changes in your transaction to be large, you can specify the NO AUTO UNDO option<br />

in your SET TRANSACTION statement, or – if you use the API – set the TPB flag isc_tpb_no_auto_undo.<br />

Both prevent the creation of the transaction-level savepoint.<br />

Savepoints and PSQL<br />

Transaction control statements are not allowed in PSQL, as that would break the atomicity of the statement that<br />

calls the procedure. But <strong>Firebird</strong> does support the raising and handling of exceptions in PSQL, so that actions<br />

performed in stored procedures and triggers can be selectively undone without the entire procedure failing.<br />

Internally, automatic savepoints are used to:<br />

• undo all actions in a BEGIN...END block where an exception occurs;<br />

• undo all actions performed by the SP/trigger (or, in the case of a selectable SP, all actions performed since<br />

the last SUSPEND) when it terminates prematurely due to an uncaught error or exception.<br />

Each PSQL exception handling block is also bounded by automatic system savepoints.<br />

Available in: DSQL, ESQL<br />

Changed in: 2.0<br />

SET TRANSACTION<br />

Description: Starts and optionally configures a transaction.<br />

Syntax:<br />

SET TRANSACTION<br />

[NAME hostvar]<br />

[READ WRITE | READ ONLY]<br />

[ [ISOLATION LEVEL] { SNAPSHOT [TABLE STABILITY]<br />

| READ COMMITTED [[NO] RECORD_VERSION] } ]<br />

[WAIT | NO WAIT]<br />

[LOCK TIMEOUT seconds]<br />

[NO AUTO UNDO]<br />

[IGNORE LIMBO]<br />

[RESERVING | USING ]<br />

::= [, ...]<br />

::= tablename [, tablename ...]<br />

[FOR [SHARED | PROTECTED] {READ | WRITE}]<br />

::= dbhandle [, dbhandle ...]<br />

• The NAME option is only available in ESQL. It must be followed by a previously declared and initialized<br />

host-language variable. Without NAME, SET TRANSACTION applies to the default transaction.<br />

92

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!