Difference between revisions of "TXNLEVEL()"

From Recital Documentation Wiki
Jump to: navigation, search
(Products)
Line 46: Line 46:
  
 
==Products==
 
==Products==
Recital Database Server, Recital Mirage Server, Recital Terminal Developer
+
Recital, Recital Server
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]

Revision as of 16:46, 8 December 2009

Purpose

Function to return the current Transaction Level number


Syntax

TXNLEVEL()


See Also

BEGIN TRANSACTION, COMMIT, COMPLETED(), END TRANSACTION, RESET IN, ROLLBACK, ROLLBACK(), SET ROLLBACK, SET TRANSACTION, TXNISOLATION()


Description

The TXNLEVEL() function returns the current Transaction level as a number. Transactions can be nested by issuing a further BEGIN TRANSACTION when a transaction is already active. If no transaction is active, the TXNLEVEL() function returns 0. A transaction and any transactions nested within it are closed when a COMMIT, ROLLBACK or END TRANSACTION is issued.


Example

// config.db
set sql to recital
set sql on
// end of config.db
 
// Nested Transactions
? txnlevel() && 0
BEGIN TRANSACTION trans1;
? txnlevel() && 1
INSERT INTO customer
(TITLE, LAST_NAME, FIRST_NAME, INITIAL, STREET,
CITY, STATE, ZIP,LIMIT, START_DATE)
VALUES
('Ms', 'Jones', 'Susan', 'B', '177 High Street','Beverly', 'MA', '01915', 2000, date());
INSERT INTO accounts (ORD_VALUE) VALUES (30);
BEGIN TRANSACTION trans2;
? txnlevel() && 2
INSERT INTO accounts (ORD_VALUE) VALUES (60);
// Commit the trans1 transaction and any transactions
// nested in trans1
COMMIT TRANSACTION trans1;
? txnlevel() && 0
END TRANSACTION;
? txnlevel() && 0
// End of program


Products

Recital, Recital Server