ibm-information-center/dist/eclipse/plugins/i5OS.ic.db2_5.4.0.1/rbafzmstsvpt.htm

129 lines
7.2 KiB
HTML

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="dc.language" scheme="rfc1766" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<meta name="dc.date" scheme="iso8601" content="2005-09-19" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow"/>
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="keywords" content="SAVEPOINT statement, SAVEPOINT, SQL statements,
savepoint, in SAVEPOINT statement, savepoint&ndash;name, UNIQUE clause" />
<title>SAVEPOINT</title>
<link rel="stylesheet" type="text/css" href="ibmidwb.css" />
<link rel="stylesheet" type="text/css" href="ic.css" />
</head>
<body>
<a id="Top_Of_Page" name="Top_Of_Page"></a><!-- Java sync-link -->
<script language = "Javascript" src = "../rzahg/synch.js" type="text/javascript"></script>
<a name="svpt"></a>
<h2 id="svpt"><a href="rbafzmst02.htm#ToC_1261">SAVEPOINT</a></h2><a id="idx3098" name="idx3098"></a><a id="idx3099" name="idx3099"></a><a id="idx3100" name="idx3100"></a>
<p>The SAVEPOINT statement sets a savepoint within a unit of work to identify
a point in time within the unit of work to which relational database changes
can be rolled back.</p>
<a name="wq1719"></a>
<h3 id="wq1719"><a href="rbafzmst02.htm#ToC_1262">Invocation</a></h3>
<p>This statement can be embedded in an application program or issued interactively.
It is an executable statement that can be dynamically prepared.</p>
<a name="wq1720"></a>
<h3 id="wq1720"><a href="rbafzmst02.htm#ToC_1263">Authorization</a></h3>
<p>None required.</p>
<a name="wq1721"></a>
<h3 id="wq1721"><a href="rbafzmst02.htm#ToC_1264">Syntax</a></h3>
<a href="rbafzmstsvpt.htm#synssavep"><img src="c.gif" alt="Click to skip syntax diagram" /></a>
<pre class="cgraphic"><span><img src="c.gif" alt="Read syntax diagram" longdesc="rbafzmstsyn376.htm"
border="0" /></span><a href="#skipsyn-375"><img src="c.gif" alt="Skip visual syntax diagram"
border="0" /></a>>>-SAVEPOINT--<span class="italic">savepoint-name</span>--+--------+------------------------>
'-UNIQUE-'
(1)
.-ON ROLLBACK RETAIN LOCKS--------.
>--ON ROLLBACK RETAIN CURSORS--+---------------------------------+->&lt;
</pre>
<a name="skipsyn-375" id="skipsyn-375"></a>
<a name="wq1722"></a>
<div class="notelisttitle" id="wq1722">Notes:</div>
<ol type="1">
<li>The ROLLBACK options can be specified in any order.</li>
</ol>
<a name="synssavep"></a>
<h3 id="synssavep"><a href="rbafzmst02.htm#ToC_1265">Description</a></h3>
<dl class="parml">
<dt class="bold"><var class="pv">savepoint-name</var> </dt><a id="idx3101" name="idx3101"></a>
<dd>Identifies a new savepoint.
</dd>
<dt class="bold">UNIQUE </dt><a id="idx3102" name="idx3102"></a>
<dd>Specifies that the application program cannot reuse the savepoint name
within the unit of work. An error occurs if a savepoint with the same name
as <var class="pv">savepoint-name</var> already exists within the unit of work.
<p>Omitting
UNIQUE indicates that the application can reuse the savepoint name within
the unit of work. If <var class="pv">savepoint-name</var> identifies a savepoint that already
exists within the unit of work and the savepoint was not created with the
UNIQUE option, the existing savepoint is destroyed and a new savepoint is
created. Destroying a savepoint to reuse its name for another savepoint is
not the same as releasing the savepoint. Reusing a savepoint name destroys
only one savepoint. Releasing a savepoint with the RELEASE SAVEPOINT statement
releases the savepoint and all savepoints that have been subsequently set.</p>
</dd>
<dt class="bold">ON ROLLBACK RETAIN CURSORS</dt>
<dd>Specifies that cursors that are opened after the savepoint is set are
not closed upon rollback to the savepoint.
<ul>
<li>If SQL schema statements are executed for a table or view within
the scope of the SAVEPOINT statement, any cursor that references that table
or view is closed. Attempts to use such a cursor after a ROLLBACK TO SAVEPOINT
results in an error.</li>
<li>Otherwise, the cursor is not affected by the ROLLBACK TO SAVEPOINT (it
remains open and positioned).</li></ul>Although these cursors remain open after rollback to the savepoint, they
might not be usable. For example, if rolling back to the savepoint causes
the insertion of a row on which the cursor is positioned to be rolled back,
using the cursor to update or delete the row results in an error.
</dd>
<dt class="bold">ON ROLLBACK RETAIN LOCKS</dt>
<dd>Specifies that any locks that are acquired after the savepoint is set
are not released on rollback to the savepoint.
</dd>
</dl>
<a name="wq1724"></a>
<h3 id="wq1724"><a href="rbafzmst02.htm#ToC_1266">Note</a></h3>
<p><span class="bold">Effect on INSERT:</span> In an application, inserts may
be buffered. The buffer will be flushed when SAVEPOINT, ROLLBACK, or RELEASE
TO SAVEPOINT statements are issued.</p>
<p><span class="bold">SAVEPOINT Restriction:</span> A SAVEPOINT statement is not
allowed if commitment control is not active for the activation group. For
information on determining which commitment definition is used, see <a href="rbafzmstc4comit.htm#macomm">Notes</a>.</p>
<a name="wq1725"></a>
<h3 id="wq1725"><a href="rbafzmst02.htm#ToC_1267">Example</a></h3>
<p>Assume that you want to set three savepoints at various points in a unit
of work. Name the first savepoint A and allow the savepoint name to be reused.
Name the second savepoint B and do not allow the name to be reused. Because
you no longer need savepoint A when you are ready to set the third savepoint,
reuse A as the name of the savepoint.</p>
<pre class="xmp"> <span class="bold">SAVEPOINT</span> A <span class="bold">ON ROLLBACK RETAIN CURSORS</span>;
.
.
.
<span class="bold">SAVEPOINT</span> B <span class="bold">UNIQUE ON ROLLBACK RETAIN CURSORS</span>;
.
.
.
<span class="bold">SAVEPOINT</span> A <span class="bold">ON ROLLBACK RETAIN CURSORS</span>;</pre><a id="idx3103" name="idx3103"></a><a id="idx3104" name="idx3104"></a>
<hr /><br />
[ <a href="#Top_Of_Page">Top of Page</a> | <a href="rbafzmstrollbac.htm">Previous Page</a> | <a href="rbafzmsthselectstmt.htm">Next Page</a> | <a href="rbafzmst02.htm#wq1">Contents</a> |
<a href="rbafzmstindex.htm#index">Index</a> ]
<a id="Bot_Of_Page" name="Bot_Of_Page"></a>
</body>
</html>