HPlogo ALLBASE/SQL Reference Manual: HP 9000 Computer Systems > Chapter 12 SQL Statements S - Z

SAVEPOINT

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

The SAVEPOINT statement defines a savepoint within a transaction. DBEnvironment changes made after a savepoint can be undone at any time prior to the end of the transaction. A transaction can have multiple savepoints.

Scope

ISQL or Application Programs

SQL Syntax

  SAVEPOINT [:HostVariable 
             :LocalVariable 
             :ProcedureParameter]

Parameters

HostVariable

identifies an output host variable used to communicate the savepoint number. The host variable's value can be from 1 to (231)-1. In an application program, you must use a host variable with the SAVEPOINT statement. In a procedure, you must use either a local variable or a procedure parameter with the SAVEPOINT statement.

When you enter a SAVEPOINT statement interactively, you cannot specify a host variable. ISQL assigns and displays the savepoint number as follows:

   isql=> savepoint;
   Savepoint number is n.
   Use this number to do ROLLBACK WORK to n.
LocalVariable

contains a value in a procedure. Identifies an output host variable used to communicate the savepoint number. The host variable's value can be from 1 to (231)-1.

ProcedureParameter

contains a value that is passed into or out of a procedure. Identifies an output host variable used to communicate the savepoint number. The host variable's value can be from 1 to (231)-1.

Description

  • Specify the savepoint number in the TO clause of a ROLLBACK WORK statement to roll back to a savepoint.

  • If a procedure invoked by a rule executes a COMMIT WORK statement, an error occurs.

Authorization

You do not need authorization to use the SAVEPOINT statement.

Example

Transaction begins.

   BEGIN WORK
   statement-1
   SAVEPOINT :MyVariable
   statement-2
   statement-3

Work of statements 2 and 3 is undone.

   ROLLBACK WORK
          TO :MyVariable

Work of statement-1 is committed; transaction ends.

   COMMIT WORK
Feedback to webmaster