Difference between revisions of "SAVE TRANSACTION"

From Recital Documentation Wiki
Jump to: navigation, search
 
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=SAVE TRANSACTION=
 
 
 
==Class==
 
SQL Applications
 
 
 
 
==Purpose==
 
==Purpose==
 
Identifies a stage within a transaction which can subsequently be used as ROLLBACK point.
 
Identifies a stage within a transaction which can subsequently be used as ROLLBACK point.
Line 28: Line 21:
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
// config.db
+
BEGIN TRANSACTION parent_and_child
set sql to recital
+
  INSERT INTO customer;
set sql on
+
    (TITLE, LAST_NAME, FIRST_NAME, INITIAL, STREET,;
// end of config.db
+
    CITY, STATE, ZIP,LIMIT, START_DATE);
 
+
    VALUES;
// SAVE TRANSACTION <savepoint>
+
    ('Ms', 'Jones', 'Susan', 'B', '177 High Street', 'Beverly', 'MA', '01915', 2000, date())
BEGIN TRANSACTION parent_and_child;
+
  SAVE TRANSACTION parent_added
INSERT INTO customer
+
  INSERT INTO accounts (ORD_VALUE) VALUES (30)
(TITLE, LAST_NAME, FIRST_NAME, INITIAL, STREET,
+
  ROLLBACK TRANSACTION parent_added
CITY, STATE, ZIP,LIMIT, START_DATE)
+
END TRANSACTION
VALUES
+
('Ms', 'Jones', 'Susan', 'B', '177 High Street', 'Beverly', 'MA', '01915', 2000, date());
+
SAVE TRANSACTION parent_added;
+
INSERT INTO accounts (ORD_VALUE) VALUES (30);
+
ROLLBACK TRANSACTION parent_added;
+
END TRANSACTION;
+
 
// End of program
 
// End of program
 
</code>
 
</code>
Line 49: Line 36:
  
 
==Products==
 
==Products==
Recital Database Server, Recital Mirage Server, Recital Terminal Developer
+
Recital Server, Recital  
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:SQL|SAVE TRANSACTION]]
 
[[Category:SQL|SAVE TRANSACTION]]
 
[[Category:Commands]]
 
[[Category:Commands]]

Latest revision as of 15:33, 22 December 2009

Purpose

Identifies a stage within a transaction which can subsequently be used as ROLLBACK point.


Syntax

SAVE TRANSACTION <savepoint>


See Also

BEGIN TRANSACTION, COMMIT, END TRANSACTION, ROLLBACK, SAVEPOINT, SET TRANSACTION, TXNISOLATION(), TXNLEVEL()


Description

The SAVE TRANSACTION statement identifies a stage within a transaction which can subsequently be used as ROLLBACK point. The name of the savepoint is specified in <savepoint>.

Issuing the SAVE TRANSACTION <savepoint> statement causes the TXNLEVEL() to increase by 1. If the transaction is rolled back to the <savepoint> using the ROLLBACK command, the TXNLEVEL will decrease by 1 and a partial rollback of the transaction will be carried out. Changes made since the specified <savepoint> was declared are discarded and the transaction continues from the <savepoint>.

A transaction is a sequence of SQL statements that Recital treats as a single unit. A transaction begins with the first executable SQL statement after a BEGIN TRANSACTION. A transaction ends with a COMMIT, ROLLBACK or END TRANSACTION.


Example

BEGIN TRANSACTION parent_and_child
  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())
  SAVE TRANSACTION parent_added
  INSERT INTO accounts (ORD_VALUE) VALUES (30)
  ROLLBACK TRANSACTION parent_added
END TRANSACTION
// End of program


Products

Recital Server, Recital