ibm-information-center/dist/eclipse/plugins/i5OS.ic.sqlp_5.4.0.1/rbafycmprec.htm

72 lines
4.9 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<?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 lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<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="DC.Type" content="reference" />
<meta name="DC.Title" content="Unit of work and open cursors" />
<meta name="abstract" content="When your program completes a unit of work, it should commit or roll back the changes you made." />
<meta name="description" content="When your program completes a unit of work, it should commit or roll back the changes you made." />
<meta name="DC.subject" content="unit of work, effect on open cursor, cursor, open during a unit of work, WITH HOLD clause, open effect of recovery on" />
<meta name="keywords" content="unit of work, effect on open cursor, cursor, open during a unit of work, WITH HOLD clause, open effect of recovery on" />
<meta name="DC.Relation" scheme="URI" content="rbafycurs.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafydynmic.htm" />
<meta name="DC.Relation" scheme="URI" content="../rzakj/rzakjcommitkickoff.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rbafycmprec" />
<meta name="DC.Language" 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. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Unit of work and open cursors</title>
</head>
<body id="rbafycmprec"><a name="rbafycmprec"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Unit of work and open cursors</h1>
<div><p>When your program completes a unit of work, it should commit or
roll back the changes you made.</p>
<div class="section"><p>Unless you specified HOLD on the COMMIT or ROLLBACK statement,
all open cursors are automatically closed by SQL. Cursors that are declared
with the WITH HOLD clause are not automatically closed on COMMIT. They are
automatically closed on a ROLLBACK (the WITH HOLD clause specified on the
DECLARE CURSOR statement is ignored).</p>
</div>
<div class="section"><p>If you want to continue processing from the current cursor position
after a COMMIT or ROLLBACK, you must specify COMMIT HOLD or ROLLBACK HOLD.
When HOLD is specified, any open cursors are left open and keep their cursor
position so processing can resume. On a COMMIT statement, the cursor position
is maintained. On a ROLLBACK statement, the cursor position is restored to
just after the last row retrieved from the previous unit of work. All record
locks are still released.</p>
</div>
<div class="section"><div class="p">After issuing a COMMIT or ROLLBACK statement without HOLD, all
locks are released and all cursors are closed. You can open the cursor again,
but you will begin processing at the first row of the result table. <div class="note"><span class="notetitle">Note:</span> Specification
of the ALWBLK(*ALLREAD) parameter of the CRTSQL<var class="varname">xxx</var> commands
can change the restoration of the cursor position for read-only cursors. See <a href="rbafydynmic.htm#rbafydynmic">Dynamic SQL applications</a> for information on the use of
the ALWBLK parameter and other performance related options on the CRTSQL<var class="varname">xxx</var> commands.</div>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafycurs.htm" title="When SQL runs a select statement, the resulting rows comprise the result table. A cursor provides a way to access a result table.">Use a cursor</a></div>
</div>
<div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="rbafydynmic.htm" title="Dynamic SQL allows an application to define and run SQL statements at program run time. An application that provides for dynamic SQL accepts as input (or builds) an SQL statement in the form of a character string. The application does not need to know what type of SQL statement it will run.">Dynamic SQL applications</a></div>
</div>
<div class="relinfo"><strong>Related information</strong><br />
<div><a href="../rzakj/rzakjcommitkickoff.htm">Commitment control</a></div>
</div>
</div>
</body>
</html>