Previous Topic

Next Topic

Savepoint

Valid in: SQL, ESQL

The Savepoint statement declares a named savepoint marker within a transaction. Savepoints can be used in conjunction with the rollback statement to rollback a transaction to the specified savepoint when necessary. Using savepoints can eliminate the need to roll back an entire transaction if it is not necessary.

Note: This statement has additional considerations when used in a distributed environment. For more information, see the Ingres Star User Guide.

Previous Topic

Next Topic

Syntax

The Savepoint statement has the following format:

[EXEC SQL] SAVEPOINT savepoint_name;

Previous Topic

Next Topic

Embedded Usage

An embedded Savepoint statement cannot be issued when a cursor is open. Savepoint_name cannot be specified with a host language variable.

Previous Topic

Next Topic

Permissions

All users are permitted to use this statement.

Previous Topic

Next Topic

Related Statements

Commit

Rollback

Previous Topic

Next Topic

Example: Savepoint

The following example declares savepoints among other SQL statements:

exec sql insert into emp (name, sal, bdate)
        values ('Jones,Bill', 10000, 1945);
/*set first savepoint marker */
exec sql savepoint setone;
exec sql insert into emp (name, sal, bdate)
        values ('Smith,Stan', 20000, 1948);
/* set second savepoint marker */
exec sql savepoint 2;
exec sql insert into emp (name, sal, bdate)
        values ('Engel,Harry', 18000, 1954);
/* undo third append;first and second remain */
exec sql rollback to 2;
/* undoes second append; first remains */
exec sql rollback to setone;
exec sql commit;
/* only the first append is committed */


© 2007 Ingres Corporation. All rights reserved.