Oracle8i SQL Reference
Release 2 (8.1.6)

A76989-01

Library

Product

Contents

Index

Prev Up Next

SQL Statements (continued), 6 of 6


SAVEPOINT

Syntax


Purpose

To identify a point in a transaction to which you can later roll back.

See Also:

 

Prerequisites

None.

Keywords and Parameters

savepoint 

is the name of the savepoint to be created.

Savepoint names must be distinct within a given transaction. If you create a second savepoint with the same identifier as an earlier savepoint, the earlier savepoint is erased. After a savepoint has been created, you can either continue processing, commit your work, roll back the entire transaction, or roll back to the savepoint.  

Example

To update BLAKE's and CLARK's salary, check that the total company salary does not exceed 27,000, then reenter CLARK's salary, enter:

UPDATE emp 
    SET sal = 2000 
    WHERE ename = 'BLAKE';
SAVEPOINT blake_sal;

UPDATE emp 
    SET sal = 1500 
    WHERE ename = 'CLARK';
SAVEPOINT clark_sal;

SELECT SUM(sal) FROM emp;

ROLLBACK TO SAVEPOINT blake_sal;
 
UPDATE emp 
    SET sal = 1200 
    WHERE ename = 'CLARK';
 
COMMIT; 

Prev Up Next
Oracle
Copyright © 1999 Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index