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

94 lines
4.8 KiB
HTML
Raw 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="Setting the cursor position" />
<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="rlacurs" />
<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>Setting the cursor position</title>
</head>
<body id="rlacurs"><a name="rlacurs"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Setting the cursor position</h1>
<div><p></p>
<div class="section"><p>An open file has a cursor. The cursor points to the record to
be read, updated, or deleted. When a file is first opened the cursor points
to the beginning of the file. The beginning of the file is before the first
record. Use the following methods to set the cursor position:</p>
</div>
<div class="section"><ul><li><a href="javadoc/com/ibm/as400/access/AS400File.html#POSITIONCURSORAFTERLAST()"> positionCursorAfterLast()</a> - Set cursor to after the
last record. This method exists so Java™ programs can use the readPrevious()
method to access records in the file.</li>
<li><a href="javadoc/com/ibm/as400/access/AS400File.html#POSITIONCURSORBEFOREFIRST()"> positionCursorBeforeFirst()</a> - Set cursor to before the
first record. This method exists so Java programs can use the readNext() method
to access records in the file.</li>
<li><a href="javadoc/com/ibm/as400/access/AS400File.html#POSITIONCURSORTOFIRST()"> positionCursorToFirst()</a> - Set the cursor to the first
record.</li>
<li><a href="javadoc/com/ibm/as400/access/AS400File.html#POSITIONCURSORTOLAST()"> positionCursorToLast()</a> - Set the cursor to the last
record.</li>
<li><a href="javadoc/com/ibm/as400/access/AS400File.html#POSITIONCURSORTONEXT()"> positionCursorToNext()</a> - Move the cursor to the next
record.</li>
<li><a href="javadoc/com/ibm/as400/access/AS400File.html#POSITIONCURSORTOPREVIOUS()"> positionCursorToPrevious()</a> - Move the cursor to the
previous record.</li>
</ul>
</div>
<div class="section"><p>The following example shows how to use the positionCursorToFirst()
method to position the cursor.</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, 1, AS400File.COMMIT_LOCK_LEVEL_NONE);
// I want to delete the first record of the file.
myFile.positionCursorToFirst();
myFile.deleteCurrentRecord();
....
// 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>