ibm-information-center/dist/eclipse/plugins/i5OS.ic.dbp_5.4.0.1/rbafoupdbr.htm

81 lines
5.7 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 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="concept" />
<meta name="DC.Title" content="Update database records" />
<meta name="abstract" content="The update operation allows you to change an existing database record in a logical or physical file." />
<meta name="description" content="The update operation allows you to change an existing database record in a logical or physical file." />
<meta name="DC.subject" content="updating, database record, record" />
<meta name="keywords" content="updating, database record, record" />
<meta name="DC.Relation" scheme="URI" content="rbafobasicop.htm" />
<meta name="DC.Relation" scheme="URI" content="../rzakj/rzakjcommitkickoff.htm" />
<meta name="DC.Relation" scheme="URI" content="rbaforzahftra.htm" />
<meta name="DC.Relation" scheme="URI" content="rbaforzahfrca.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="rbafoupdbr" />
<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>Update database records</title>
</head>
<body id="rbafoupdbr"><a name="rbafoupdbr"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Update database records</h1>
<div><p>The update operation allows you to change an existing database
record in a logical or physical file. </p>
<p> The UPDAT statement in the RPG/400<sup>®</sup> language and the REWRITE statement
in the COBOL/400<sup>®</sup> language
are examples of this operation. Before you update a database record, the record
must first be read and locked. The lock is obtained by specifying the update
option on any of the read operations listed under the <a href="rbafordbra.htm#rbafordbra">Read database records using an arrival sequence access path</a> or <a href="rbafordbrk.htm#rbafordbrk">Read database records using a keyed sequence access path</a>.</p>
<div class="p">If you issue several read operations with the update option specified,
each read operation releases the lock on the previous record before attempting
to locate and lock the new record. When you do the update operation, the system
assumes that you are updating the currently locked record. Therefore, you
do not have to identify the record to be updated on the update operation.
After the update operation is done, the system releases the lock. <div class="note"><span class="notetitle">Note:</span> The
rules for locking are different if your job is running under commitment control. </div>
</div>
<p>If the update operation changes a key field in an access path for which
immediate maintenance is specified, the access path is updated if the high-level
language allows it. (Some high-level languages do not allow changes to the
key field in an update operation.)</p>
<p>If you request a read operation on a record that is already locked for
update and if your job is running under a commitment control level of *ALL
or *CS (cursor stability), then you must wait until the record is released
or the time specified by the WAITRCD parameter on the create file or override
commands has been exceeded. If the WAITRCD time is exceeded without the lock
being released, an exception is returned to your program and a message is
sent to your job stating the file, member, relative record number, and the
job which has the lock. If the job that is reading records is not running
under a commitment control level of *ALL or *CS, the job is able to read a
record that is locked for update.</p>
<p>If the file you are updating has an update trigger associated with it,
the trigger program is called before or after updating the record.</p>
<p>If the files being updated are associated with referential constraints,
the update operation can be affected.</p>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafobasicop.htm" title="These topics describe basic database file operations, including the read, update, write and delete operations.">Basic database file operations in programs</a></div>
</div>
<div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="../rzakj/rzakjcommitkickoff.htm">Commitment control</a></div>
<div><a href="rbaforzahftra.htm" title="A trigger is a set of actions that run automatically when a specified change or read operation is performed on a specified database file. On iSeries, you define a set of trigger actions in any supported high-level language.">Trigger automatic events in your database</a></div>
<div><a href="rbaforzahfrca.htm" title="These topics discuss how to use referential constraints in your database to ensure that it contains only valid data.">Ensure data integrity with referential constraints</a></div>
</div>
</div>
</body>
</html>