102 lines
6.9 KiB
HTML
102 lines
6.9 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="Set a position in the file" />
|
|
<meta name="abstract" content="After a file is opened by a job, the system maintains a position in the file for that job. The file position is used in processing the file." />
|
|
<meta name="description" content="After a file is opened by a job, the system maintains a position in the file for that job. The file position is used in processing the file." />
|
|
<meta name="DC.subject" content="setting position in file, position, setting in a file, database file, setting a position" />
|
|
<meta name="keywords" content="setting position in file, position, setting in a file, database file, setting a position" />
|
|
<meta name="DC.Relation" scheme="URI" content="rbafobasicop.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../cl/ovrdbf.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../rbam6/rbam6clmain.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rbafoefdel.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="rbafodbfpo" />
|
|
<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>Set a position in the file</title>
|
|
</head>
|
|
<body id="rbafodbfpo"><a name="rbafodbfpo"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Set a position in the file</h1>
|
|
<div><p>After a file is opened by a job, the system maintains a position
|
|
in the file for that job. The file position is used in processing the file. </p>
|
|
<p> For example, if a program does a read operation requesting the next sequential
|
|
record, the system uses the file position to determine which record to return
|
|
to the program. The system then sets the file position to the record just
|
|
read, so that another read operation requesting the next sequential record
|
|
can return the correct record. The system keeps track of all file positions
|
|
for each job. In addition, each job can have multiple positions in the same
|
|
file.</p>
|
|
<p>The
|
|
file position is first set to the position specified in the POSITION parameter
|
|
on the Override with Database File (OVRDBF) command. If you do not use an
|
|
OVRDBF command, or if you take the default for the POSITION parameter, the
|
|
file position is set just before the first record in the member's access path.</p>
|
|
<div class="p">A program can change the current file position by using the appropriate
|
|
high-level language program file positioning operation (for example, SETLL
|
|
in the RPG/400<sup>®</sup> language
|
|
or START in the COBOL/400<sup>®</sup> language).
|
|
A program can also change the file position by using the Position Database
|
|
File (POSDBF) command. <div class="note"><span class="notetitle">Note:</span> File positioning by means of the OVRDBF command
|
|
does not occur until the next time the file is opened. Because a file can
|
|
be opened only once within a control language (CL) program, this command cannot
|
|
be used within a single CL program to affect what is read through the Receive
|
|
File (RCVF) command.</div>
|
|
</div>
|
|
<p>At end of file, after the last read, the file member is positioned to *START
|
|
or *END file position, depending on whether the program was reading forward
|
|
or backward through the file. The following diagram shows *START and *END
|
|
file positions. *START is at the top, with three records following, and *END
|
|
at the bottom.</p>
|
|
<br /><img src="rbafo540.gif" alt="Example of a file" /><br /><p>Only a read operation, force-end-of-data operation, high-level language
|
|
positioning operation, or specific CL command to change the file position
|
|
can change the file position. Add, update, and delete operations do not change
|
|
the file position. After a read operation, the file is positioned to the new
|
|
record. This record is then returned to your program. After the read operation
|
|
is completed, the file is positioned at the record just returned to your program.
|
|
If the member is open for input, a force-end-of-data operation positions the
|
|
file after the last record in the file (*END) and sends the end-of-file message
|
|
to your program.</p>
|
|
<p>For sequential read operations, the current file position is used to locate
|
|
the next or previous record on the access path. For read-by-key or read-by-relative-record-number
|
|
operations, the file position is not used. If POSITION(*NONE) is specified
|
|
at open time, no starting file position is set. In this case, you must establish
|
|
a file position in your program, if you are going to read sequentially.</p>
|
|
<p>If end-of-file delay was specified for the file on an OVRDBF command, the
|
|
file is not positioned to *START or *END when the program reads the last record.
|
|
The file remains positioned at the last record read. A file with end-of-file
|
|
delay processing specified is positioned to *START or *END only when a force-end-of-data
|
|
(FEOD) occurs or a controlled job end occurs. </p>
|
|
<p>You can also use the POSDBF command to set or change the current position
|
|
in your file for files opened using either the Open Database File (OPNDBF)
|
|
command or the Open Query File (OPNQRYF) command.</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="../rbam6/rbam6clmain.htm">Control language (CL)</a></div>
|
|
<div><a href="rbafoefdel.htm" title="End-of-file delay is a method of continuing to read sequentially from a database file (logical or physical) after an end-of-file condition occurs.">Wait for more records when end of file is reached</a></div>
|
|
</div>
|
|
<div class="relref"><strong>Related reference</strong><br />
|
|
<div><a href="../cl/ovrdbf.htm">Override with Database File (OVRDBF) command</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |