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

293 lines
20 KiB
HTML
Raw Permalink 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="concept" />
<meta name="DC.Title" content="Use more than one key field" />
<meta name="abstract" content="You can use more than one key field to arrange the records in a database file. The key fields do not have to use the same sequence." />
<meta name="description" content="You can use more than one key field to arrange the records in a database file. The key fields do not have to use the same sequence." />
<meta name="DC.subject" content="key field, using multiple, field, using, multiple key" />
<meta name="keywords" content="key field, using multiple, field, using, multiple key" />
<meta name="DC.Relation" scheme="URI" content="rbafoksapa.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="rbafokfield" />
<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>Use more than one key field</title>
</head>
<body id="rbafokfield"><a name="rbafokfield"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Use more than one key field</h1>
<div><p>You can use more than one key field to arrange the records in a
database file. The key fields do not have to use the same sequence. </p>
<p>For example, when you use two key fields, one field can use ascending sequence
while the other can use descending sequence. Consider the following records.</p>
<table cellpadding="4" cellspacing="0" border="1" class="tableborder"><tr><td>
<table cellpadding="4" cellspacing="0" summary="" width="100%" border="0"><thead align="left"><tr><th align="left" valign="top" width="14.285714285714285%" id="d0e36">Record</th>
<th align="left" valign="top" width="14.285714285714285%" id="d0e38">Order</th>
<th align="center" valign="top" width="14.285714285714285%" id="d0e40">Ordate</th>
<th align="left" valign="top" width="14.285714285714285%" id="d0e42">Line</th>
<th align="left" valign="top" width="14.285714285714285%" id="d0e44">Item</th>
<th align="left" valign="top" width="14.285714285714285%" id="d0e46">Qtyord</th>
<th align="left" valign="top" width="14.285714285714285%" id="d0e48">Extens</th>
</tr>
</thead>
<tbody><tr><td align="left" valign="top" width="14.285714285714285%" headers="d0e36 ">1</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e38 ">52218</td>
<td align="center" valign="top" width="14.285714285714285%" headers="d0e40 ">063088</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e42 ">01</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e44 ">88682</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e46 ">425</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e48 ">031875</td>
</tr>
<tr><td align="left" valign="top" width="14.285714285714285%" headers="d0e36 ">2</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e38 ">41834</td>
<td align="center" valign="top" width="14.285714285714285%" headers="d0e40 ">062888</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e42 ">03</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e44 ">42111</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e46 ">30</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e48 ">020550</td>
</tr>
<tr><td align="left" valign="top" width="14.285714285714285%" headers="d0e36 ">3</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e38 ">41834</td>
<td align="center" valign="top" width="14.285714285714285%" headers="d0e40 ">062888</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e42 ">02</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e44 ">61132</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e46 ">4</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e48 ">021700</td>
</tr>
<tr><td align="left" valign="top" width="14.285714285714285%" headers="d0e36 ">4</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e38 ">52218</td>
<td align="center" valign="top" width="14.285714285714285%" headers="d0e40 ">063088</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e42 ">02</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e44 ">40001</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e46 ">62</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e48 ">021700</td>
</tr>
<tr><td align="left" valign="top" width="14.285714285714285%" headers="d0e36 ">5</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e38 ">41834</td>
<td align="center" valign="top" width="14.285714285714285%" headers="d0e40 ">062888</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e42 ">01</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e44 ">00623</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e46 ">50</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e48 ">025000</td>
</tr>
</tbody>
</table>
</td></tr></table>
<p>If the access path uses the <em>Order</em> field, then the <em>Line</em> field
as the key fields, both in ascending sequence, the order of the records in
the access path is.</p>
<table cellpadding="4" cellspacing="0" border="1" class="tableborder"><tr><td>
<table cellpadding="4" cellspacing="0" summary="" width="100%" border="0"><thead align="left"><tr><th align="left" valign="top" width="14.285714285714285%" id="d0e145">Record</th>
<th align="left" valign="top" width="14.285714285714285%" id="d0e147">Order</th>
<th align="center" valign="top" width="14.285714285714285%" id="d0e149">Ordate</th>
<th align="left" valign="top" width="14.285714285714285%" id="d0e151">Line</th>
<th align="left" valign="top" width="14.285714285714285%" id="d0e153">Item</th>
<th align="left" valign="top" width="14.285714285714285%" id="d0e155">Qtyord</th>
<th align="left" valign="top" width="14.285714285714285%" id="d0e157">Extens</th>
</tr>
</thead>
<tbody><tr><td align="left" valign="top" width="14.285714285714285%" headers="d0e145 ">5</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e147 ">41834</td>
<td align="center" valign="top" width="14.285714285714285%" headers="d0e149 ">062888</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e151 ">01</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e153 ">00623</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e155 ">50</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e157 ">025000</td>
</tr>
<tr><td align="left" valign="top" width="14.285714285714285%" headers="d0e145 ">3</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e147 ">41834</td>
<td align="center" valign="top" width="14.285714285714285%" headers="d0e149 ">062888</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e151 ">02</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e153 ">61132</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e155 ">4</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e157 ">021700</td>
</tr>
<tr><td align="left" valign="top" width="14.285714285714285%" headers="d0e145 ">2</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e147 ">41834</td>
<td align="center" valign="top" width="14.285714285714285%" headers="d0e149 ">062888</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e151 ">03</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e153 ">42111</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e155 ">30</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e157 ">020550</td>
</tr>
<tr><td align="left" valign="top" width="14.285714285714285%" headers="d0e145 ">1</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e147 ">52218</td>
<td align="center" valign="top" width="14.285714285714285%" headers="d0e149 ">063088</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e151 ">01</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e153 ">88682</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e155 ">425</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e157 ">031875</td>
</tr>
<tr><td align="left" valign="top" width="14.285714285714285%" headers="d0e145 ">4</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e147 ">52218</td>
<td align="center" valign="top" width="14.285714285714285%" headers="d0e149 ">063088</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e151 ">02</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e153 ">40001</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e155 ">62</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e157 ">021700</td>
</tr>
</tbody>
</table>
</td></tr></table>
<p>If the access path uses the key field <em>Order</em> in ascending sequence,
then the <em>Line</em> field in descending sequence, the order of the records
in the access path is.</p>
<table cellpadding="4" cellspacing="0" border="1" class="tableborder"><tr><td>
<table cellpadding="4" cellspacing="0" summary="" width="100%" border="0"><thead align="left"><tr><th align="left" valign="top" width="14.285714285714285%" id="d0e254">Record</th>
<th align="left" valign="top" width="14.285714285714285%" id="d0e256">Order</th>
<th align="center" valign="top" width="14.285714285714285%" id="d0e258">Ordate</th>
<th align="left" valign="top" width="14.285714285714285%" id="d0e260">Line</th>
<th align="left" valign="top" width="14.285714285714285%" id="d0e262">Item</th>
<th align="left" valign="top" width="14.285714285714285%" id="d0e264">Qtyord</th>
<th align="left" valign="top" width="14.285714285714285%" id="d0e266">Extens</th>
</tr>
</thead>
<tbody><tr><td align="left" valign="top" width="14.285714285714285%" headers="d0e254 ">2</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e256 ">41834</td>
<td align="center" valign="top" width="14.285714285714285%" headers="d0e258 ">062888</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e260 ">03</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e262 ">42111</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e264 ">30</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e266 ">020550</td>
</tr>
<tr><td align="left" valign="top" width="14.285714285714285%" headers="d0e254 ">3</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e256 ">41834</td>
<td align="center" valign="top" width="14.285714285714285%" headers="d0e258 ">062888</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e260 ">02</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e262 ">61132</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e264 ">4</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e266 ">021700</td>
</tr>
<tr><td align="left" valign="top" width="14.285714285714285%" headers="d0e254 ">5</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e256 ">41834</td>
<td align="center" valign="top" width="14.285714285714285%" headers="d0e258 ">062888</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e260 ">01</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e262 ">00623</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e264 ">50</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e266 ">025000</td>
</tr>
<tr><td align="left" valign="top" width="14.285714285714285%" headers="d0e254 ">4</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e256 ">52218</td>
<td align="center" valign="top" width="14.285714285714285%" headers="d0e258 ">063088</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e260 ">02</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e262 ">40001</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e264 ">62</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e266 ">021700</td>
</tr>
<tr><td align="left" valign="top" width="14.285714285714285%" headers="d0e254 ">1</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e256 ">52218</td>
<td align="center" valign="top" width="14.285714285714285%" headers="d0e258 ">063088</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e260 ">01</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e262 ">88682</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e264 ">425</td>
<td align="left" valign="top" width="14.285714285714285%" headers="d0e266 ">031875</td>
</tr>
</tbody>
</table>
</td></tr></table>
<p>When a record has key fields whose contents are the same as the key field
in another record in the same file, then the file is said to have records
with duplicate key values. However, the duplication must occur for <em>all</em> key
fields for a record if they are to be called duplicate key values. For example,
if a record format has two key fields <em>Order</em> and <em>Ordate</em>, duplicate
key values occur when the contents of both the <em>Order</em> and <em>Ordate</em> fields
are the same in two or more records. These records have duplicate key values.</p>
<table cellpadding="4" cellspacing="0" border="1" class="tableborder"><tr><td>
<table cellpadding="4" cellspacing="0" summary="" width="100%" border="0"><thead align="left"><tr><th align="left" valign="top" width="16.666666666666664%" id="d0e371">Order</th>
<th align="left" valign="top" width="16.666666666666664%" id="d0e373">Ordate</th>
<th align="left" valign="top" width="16.666666666666664%" id="d0e375">Line</th>
<th align="left" valign="top" width="16.666666666666664%" id="d0e377">Item</th>
<th align="left" valign="top" width="16.666666666666664%" id="d0e379">Qtyord</th>
<th align="left" valign="top" width="16.666666666666664%" id="d0e381">Extens</th>
</tr>
</thead>
<tbody><tr><td align="left" valign="top" width="16.666666666666664%" headers="d0e371 ">41834</td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e373 ">062888</td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e375 ">03</td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e377 ">42111</td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e379 ">30</td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e381 ">020550</td>
</tr>
<tr><td align="left" valign="top" width="16.666666666666664%" headers="d0e371 ">41834</td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e373 ">062888</td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e375 ">02</td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e377 ">61132</td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e379 ">04</td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e381 ">021700</td>
</tr>
<tr><td align="left" valign="top" width="16.666666666666664%" headers="d0e371 ">41834</td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e373 ">062888</td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e375 ">01</td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e377 ">00623</td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e379 ">50</td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e381 ">025000</td>
</tr>
</tbody>
</table>
</td></tr></table>
<p>Using the <em>Line</em> field as a third key field defines the file so that
there are no duplicate keys.</p>
<table cellpadding="4" cellspacing="0" border="1" class="tableborder"><tr><td>
<table cellpadding="4" cellspacing="0" summary="" width="100%" border="0"><thead align="left"><tr><th align="left" valign="bottom" width="20.13888888888889%" id="d0e438">(First key field) order</th>
<th align="left" valign="bottom" width="19.96527777777778%" id="d0e440">(Second key field) ordate</th>
<th align="left" valign="bottom" width="19.618055555555554%" id="d0e442">(Third key field) line</th>
<th align="left" valign="bottom" width="14.23611111111111%" id="d0e444">Item</th>
<th align="left" valign="bottom" width="13.020833333333334%" id="d0e446">Qtyord</th>
<th align="left" valign="bottom" width="13.020833333333334%" id="d0e448">Extens</th>
</tr>
</thead>
<tbody><tr><td align="left" valign="top" width="20.13888888888889%" headers="d0e438 ">41834</td>
<td align="left" valign="top" width="19.96527777777778%" headers="d0e440 ">062888</td>
<td align="left" valign="top" width="19.618055555555554%" headers="d0e442 ">03</td>
<td align="left" valign="top" width="14.23611111111111%" headers="d0e444 ">42111</td>
<td align="left" valign="top" width="13.020833333333334%" headers="d0e446 ">30</td>
<td align="left" valign="top" width="13.020833333333334%" headers="d0e448 ">020550</td>
</tr>
<tr><td align="left" valign="top" width="20.13888888888889%" headers="d0e438 ">41834</td>
<td align="left" valign="top" width="19.96527777777778%" headers="d0e440 ">062888</td>
<td align="left" valign="top" width="19.618055555555554%" headers="d0e442 ">02</td>
<td align="left" valign="top" width="14.23611111111111%" headers="d0e444 ">61132</td>
<td align="left" valign="top" width="13.020833333333334%" headers="d0e446 ">04</td>
<td align="left" valign="top" width="13.020833333333334%" headers="d0e448 ">021700</td>
</tr>
<tr><td align="left" valign="top" width="20.13888888888889%" headers="d0e438 ">41834</td>
<td align="left" valign="top" width="19.96527777777778%" headers="d0e440 ">062888</td>
<td align="left" valign="top" width="19.618055555555554%" headers="d0e442 ">01</td>
<td align="left" valign="top" width="14.23611111111111%" headers="d0e444 ">00623</td>
<td align="left" valign="top" width="13.020833333333334%" headers="d0e446 ">50</td>
<td align="left" valign="top" width="13.020833333333334%" headers="d0e448 ">025000</td>
</tr>
</tbody>
</table>
</td></tr></table>
<p>A logical file that has more than one record format can have records with
duplicate key values, even though the record formats are based on different
physical files. That is, even though the key values come from different record
formats, they are considered duplicate key values.</p>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafoksapa.htm" title="A keyed sequence access path for database files is based on the contents of the key fields as defined in data description specifications (DDS). This topic describes how the key fields are arranged for the file.">Use a keyed sequence access path for database files</a></div>
</div>
</div>
</body>
</html>