ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzahh_5.4.0.1/rlaseq.htm

121 lines
5.8 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="reference" />
<meta name="DC.Title" content="SequentialFile" />
<meta name="abstract" content="" />
<meta name="description" content="" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rlaseq" />
<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>SequentialFile</title>
</head>
<body id="rlaseq"><a name="rlaseq"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">SequentialFile</h1>
<div><p></p>
<div class="section"><p>The <a href="javadoc/com/ibm/as400/access/SequentialFile.html#NAVBAR_TOP"> SequentialFile</a> class gives a Java™ program access to a file on the server
by record number. Methods exist to position the cursor, read, update, and
delete records by record number.</p>
</div>
<div class="section"><p>To position the cursor, use the following methods:</p>
</div>
<div class="section"><ul><li><a href="javadoc/com/ibm/as400/access/SequentialFile.html#POSITIONCURSOR(INT)"> positionCursor(int)</a> - set cursor to the record with
the specified record number.</li>
<li><a href="javadoc/com/ibm/as400/access/SequentialFile.html#POSITIONCURSORAFTER(INT)"> positionCursorAfter(int)</a> - set cursor to the record
after the specified record number.</li>
<li><a href="javadoc/com/ibm/as400/access/SequentialFile.html#POSITIONCURSORBEFORE(INT)"> positionCursorBefore(int)</a> - set cursor to the record
before the specified record number.</li>
</ul>
</div>
<div class="section"><p>To delete a record, use the following method:</p>
</div>
<div class="section"><ul><li><a href="javadoc/com/ibm/as400/access/SequentialFile.html#DELETERECORD(INT)"> deleteRecord(int)</a> - delete the record with the specified
record number.</li>
</ul>
</div>
<div class="section"><p>To read a record, use the following methods:</p>
</div>
<div class="section"><ul><li><a href="javadoc/com/ibm/as400/access/SequentialFile.html#READ(INT)"> read(int)</a> - read the record with the specified record
number.</li>
<li><a href="javadoc/com/ibm/as400/access/SequentialFile.html#READAFTER(INT)"> readAfter(int)</a> - read the record after the specified
record number.</li>
<li><a href="javadoc/com/ibm/as400/access/SequentialFile.html#READBEFORE(INT)"> readBefore(int)</a> - read the record before the specified
record number.</li>
</ul>
</div>
<div class="section"><p>To update a record, use the following method:</p>
</div>
<div class="section"><ul><li><a href="javadoc/com/ibm/as400/access/SequentialFile.html#UPDATE(INT, COM.IBM.AS400.ACCESS.RECORD)"> update(int)</a> - update the record with the specified record
number.</li>
</ul>
</div>
<div class="section"><p>SequentialFile is a subclass of AS400File; all methods in AS400File
are available to SequentialFile.</p>
</div>
<div class="section"><p>The following example shows how to use the SequentialFile class:</p>
</div>
<div class="section"><div class="p"><pre> // Create an AS400 object, the file exists on this
// server.
AS400 sys = new AS400("mySystem.myCompany.com");
// Create a file object that represents the file
SequentialFile myFile = new SequentialFile(sys, "/QSYS.LIB/MYLIB.LIB/MYFILE.FILE/%FILE%.MBR");
// Assume that the AS400FileRecordDescription class
// was used to generate the code for a subclass of
// RecordFormat that represents the record format
// of file MYFILE in library MYLIB. The code was
// compiled and is available for use by the Java program.
RecordFormat recordFormat = new MYFILEFormat();
// Set the record format for myFile. This must
// be done before invoking open()
myFile.setRecordFormat(recordFormat);
// Open the file.
myFile.open(AS400File.READ_WRITE, 0, AS400File.COMMIT_LOCK_LEVEL_NONE);
// Delete record number 2.
myFile.delete(2);
// Read record number 5 and update it
Record updateRec = myFile.read(5);
updateRec.setField("CUSTNAME", newName);
// Use the base class' update() method since I am
// already positioned on the record.
myFile.update(updateRec);
// Update record number 7
updateRec.setField("CUSTNAME", nextNewName);
updateRec.setField("CUSTNUM", new Integer(7));
myFile.update(7, updateRec);
....
// Close the file since I am done using it
myFile.close();
// Disconnect since I am done using record-level access
sys.disconnectService(AS400.RECORDACCESS);</pre>
</div>
</div>
</div>
</body>
</html>