Difference between revisions of "TXNLEVEL()"

From Recital Documentation Wiki
Jump to: navigation, search
 
(3 intermediate revisions by one user not shown)
Line 1: Line 1:
==Class==
 
Transaction Processing
 
 
 
 
==Purpose==
 
==Purpose==
 
Function to return the current Transaction Level number
 
Function to return the current Transaction Level number
Line 21: Line 17:
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
// config.db
 
set sql to recital
 
set sql on
 
// end of config.db
 
 
 
// Nested Transactions
 
// Nested Transactions
 
? txnlevel() && 0
 
? txnlevel() && 0
BEGIN TRANSACTION trans1;
+
BEGIN TRANSACTION trans1
? txnlevel() && 1
+
  ? txnlevel() && 1
INSERT INTO customer
+
  INSERT INTO customer;
(TITLE, LAST_NAME, FIRST_NAME, INITIAL, STREET,
+
    (TITLE, LAST_NAME, FIRST_NAME, INITIAL, STREET,;
CITY, STATE, ZIP,LIMIT, START_DATE)
+
    CITY, STATE, ZIP,LIMIT, START_DATE);
VALUES
+
    VALUES;
('Ms', 'Jones', 'Susan', 'B', '177 High Street','Beverly', 'MA', '01915', 2000, date());
+
    ('Ms', 'Jones', 'Susan', 'B', '177 High Street','Beverly', 'MA', '01915', 2000, date())
INSERT INTO accounts (ORD_VALUE) VALUES (30);
+
  INSERT INTO accounts (ORD_VALUE) VALUES (30)
BEGIN TRANSACTION trans2;
+
  BEGIN TRANSACTION trans2
? txnlevel() && 2
+
    ? txnlevel() && 2
INSERT INTO accounts (ORD_VALUE) VALUES (60);
+
    INSERT INTO accounts (ORD_VALUE) VALUES (60)
// Commit the trans1 transaction and any transactions
+
    // Commit the trans1 transaction and any transactions
// nested in trans1
+
    // nested in trans1
COMMIT TRANSACTION trans1;
+
    COMMIT TRANSACTION trans1
? txnlevel() && 0
+
    ? txnlevel() && 0
END TRANSACTION;
+
END TRANSACTION
 
? txnlevel() && 0
 
? txnlevel() && 0
// End of program
 
 
</code>
 
</code>
  
  
 
==Products==
 
==Products==
Recital Database Server, Recital Mirage Server, Recital Terminal Developer
+
Recital, Recital Server
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]

Latest revision as of 15:37, 22 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

// 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


Products

Recital, Recital Server