186 lines
9.6 KiB
HTML
186 lines
9.6 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="Random access (case 5)" />
|
|
<meta name="DC.subject" content="random access, example, random access" />
|
|
<meta name="keywords" content="random access, example, random access" />
|
|
<meta name="DC.Relation" scheme="URI" content="rbafox2phyf.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rbafoduprc.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="rbafocase5" />
|
|
<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>Random access (case 5)</title>
|
|
</head>
|
|
<body id="rbafocase5"><a name="rbafocase5"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Random access (case 5)</h1>
|
|
<div><div class="section"><p>Assume that a join logical file is specified as in <a href="rbafox2phyf.htm#rbafox2phyf">Basic concepts of joining two physical files (example 1)</a>.
|
|
Note that the join logical file has key fields defined. This case shows which
|
|
records are returned for a random access read operation using the join logical
|
|
file.</p>
|
|
<p>Assume that PF1 and PF2 have the following records.</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="border" border="1" rules="all"><caption>Table 1. Physical file 1 (PF1)</caption><thead align="left"><tr valign="bottom"><th valign="bottom" id="d0e36">Employee number</th>
|
|
<th valign="bottom" id="d0e38">Name</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td valign="top" headers="d0e36 ">235</td>
|
|
<td valign="top" headers="d0e38 ">Anne</td>
|
|
</tr>
|
|
<tr><td valign="top" headers="d0e36 ">440</td>
|
|
<td valign="top" headers="d0e38 ">Doug</td>
|
|
</tr>
|
|
<tr><td valign="top" headers="d0e36 ">500</td>
|
|
<td valign="top" headers="d0e38 ">Mark</td>
|
|
</tr>
|
|
<tr><td valign="top" headers="d0e36 ">729</td>
|
|
<td valign="top" headers="d0e38 ">Sue</td>
|
|
</tr>
|
|
<tr><td valign="top" headers="d0e36 ">997</td>
|
|
<td valign="top" headers="d0e38 ">Tim</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="border" border="1" rules="all"><caption>Table 2. Physical file 2 (PF2)</caption><thead align="left"><tr valign="bottom"><th valign="bottom" id="d0e74">Employee number</th>
|
|
<th valign="bottom" id="d0e76">Salary</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td valign="top" headers="d0e74 ">235</td>
|
|
<td valign="top" headers="d0e76 ">1700.00</td>
|
|
</tr>
|
|
<tr><td valign="top" headers="d0e74 ">440</td>
|
|
<td valign="top" headers="d0e76 ">950.50</td>
|
|
</tr>
|
|
<tr><td valign="top" headers="d0e74 ">729</td>
|
|
<td valign="top" headers="d0e76 ">1400.90</td>
|
|
</tr>
|
|
<tr><td valign="top" headers="d0e74 ">984</td>
|
|
<td valign="top" headers="d0e76 ">878.25</td>
|
|
</tr>
|
|
<tr><td valign="top" headers="d0e74 ">997</td>
|
|
<td valign="top" headers="d0e76 ">331.00</td>
|
|
</tr>
|
|
<tr><td valign="top" headers="d0e74 ">997</td>
|
|
<td valign="top" headers="d0e76 ">555.00</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<p>In PF2, no record is found for record 500, record 984 exists only
|
|
in PF2, and duplicate records are found for 997. </p>
|
|
</div>
|
|
<div class="section"><p>The program can get the following records.</p>
|
|
<p>Given a value
|
|
of 235 from the program for the <em>Nbr</em> field in the logical file, the
|
|
system supplies the following record.</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="border" border="1" rules="all"><thead align="left"><tr valign="bottom"><th valign="bottom" width="33.33333333333333%" id="d0e126">Employee number</th>
|
|
<th valign="bottom" width="33.33333333333333%" id="d0e128">Name</th>
|
|
<th valign="bottom" width="33.33333333333333%" id="d0e130">Salary</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td valign="top" width="33.33333333333333%" headers="d0e126 ">235</td>
|
|
<td valign="top" width="33.33333333333333%" headers="d0e128 ">Anne</td>
|
|
<td valign="top" width="33.33333333333333%" headers="d0e130 ">1700.00</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section"><p>Given a value of 500 from the program for the <em>Nbr</em> field
|
|
in the logical file and with the JDFTVAL keyword specified, the system supplies
|
|
the following record.</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="border" border="1" rules="all"><thead align="left"><tr valign="bottom"><th valign="bottom" width="33.33333333333333%" id="d0e153">Employee number</th>
|
|
<th valign="bottom" width="33.33333333333333%" id="d0e155">Name</th>
|
|
<th valign="bottom" width="33.33333333333333%" id="d0e157">Salary</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td valign="top" width="33.33333333333333%" headers="d0e153 ">500</td>
|
|
<td valign="top" width="33.33333333333333%" headers="d0e155 ">Mark</td>
|
|
<td valign="top" width="33.33333333333333%" headers="d0e157 ">0000.00</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="note"><span class="notetitle">Note:</span> If the JDFTVAL keyword was not specified in the join logical
|
|
file, no record is found for a value of 500 because no matching record is
|
|
contained in the secondary file.</div>
|
|
</div>
|
|
<div class="section"><p>Given a value of 984 from the program for the <em>Nbr</em> field
|
|
in the logical file, the system supplies no record and a <samp class="codeph">no record
|
|
found</samp> exception occurs because record 984 is not in the primary file.</p>
|
|
</div>
|
|
<div class="section"><p>Given a value of 997 from the program for the <em>Nbr</em> field
|
|
in the logical file, the system returns one of the following records.</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="border" border="1" rules="all"><thead align="left"><tr valign="bottom"><th valign="bottom" width="33.33333333333333%" id="d0e191">Employee number</th>
|
|
<th valign="bottom" width="33.33333333333333%" id="d0e193">Name</th>
|
|
<th valign="bottom" width="33.33333333333333%" id="d0e195">Salary</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td valign="top" width="33.33333333333333%" headers="d0e191 ">997</td>
|
|
<td valign="top" width="33.33333333333333%" headers="d0e193 ">Tim</td>
|
|
<td valign="top" width="33.33333333333333%" headers="d0e195 ">331.00</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<p>or</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="border" border="1" rules="all"><thead align="left"><tr valign="bottom"><th valign="bottom" width="33.33333333333333%" id="d0e214">Employee number</th>
|
|
<th valign="bottom" width="33.33333333333333%" id="d0e216">Name</th>
|
|
<th valign="bottom" width="33.33333333333333%" id="d0e218">Salary</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td valign="top" width="33.33333333333333%" headers="d0e214 ">997</td>
|
|
<td valign="top" width="33.33333333333333%" headers="d0e216 ">Tim</td>
|
|
<td valign="top" width="33.33333333333333%" headers="d0e218 ">555.00</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section"><div class="p">Which record is returned
|
|
to the program cannot be predicted. To specify which record is returned, specify
|
|
the JDUPSEQ keyword in the join logical file. <div class="note"><span class="notetitle">Notes:</span> <ol><li>With random access, the application programmer must be aware that duplicate
|
|
records can be contained in PF2, and ensure that the program does more than
|
|
one read operation for records with duplicate keys. If the program is using
|
|
sequential access, a second read operation gets the second record.</li>
|
|
<li>If you specify the JDUPSEQ keyword, the system can create a separate access
|
|
path for the join logical file (because there is less of a chance that the
|
|
system will find an existing access path that it can share). If you omit the
|
|
JDUPSEQ keyword, the system can share the access path of another file. (In
|
|
this case, the system can share the access path of PF2.)</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafox2phyf.htm" title="A join logical file is a logical file that combines (in one record format) fields from two or more physical files because in the record format not all the fields need to exist in all the physical files.">Basic concepts of joining two physical files (example 1)</a></div>
|
|
</div>
|
|
<div class="relref"><strong>Related reference</strong><br />
|
|
<div><a href="rbafoduprc.htm" title="Sometimes a join operation to a secondary file produces more than one record from the secondary file. When this occurs, specifying the JDUPSEQ keyword in the join specification for that secondary file tells the system to base the order of the duplicate records on the specified field in the secondary file.">Read duplicate records in secondary files (example 3)</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |