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

143 lines
8.2 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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="Example 1: Dynamically join database files without DDS" />
<meta name="abstract" content="This example shows how to dynamically join database files without DDS." />
<meta name="description" content="This example shows how to dynamically join database files without DDS." />
<meta name="DC.Relation" scheme="URI" content="rbafodynjf.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="rbafodynjfex1" />
<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>Example 1: Dynamically join database files without DDS</title>
</head>
<body id="rbafodynjfex1"><a name="rbafodynjfex1"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example 1: Dynamically join database files without DDS</h1>
<div><p>This example shows how to dynamically join database files without
DDS.</p>
<div class="section"><p>Assume that you want to join FILEA and FILEB, and the files contain
the following fields:</p>
</div>
<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="33.33333333333333%" id="d0e25">FILEA</th>
<th align="left" valign="bottom" width="33.33333333333333%" id="d0e27">FILEB</th>
<th align="left" valign="bottom" width="33.33333333333333%" id="d0e29">JOINAB</th>
</tr>
</thead>
<tbody><tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e25 ">Cust</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e27 ">Cust</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e29 ">Cust</td>
</tr>
<tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e25 ">Name</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e27 ">Amt</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e29 ">Name</td>
</tr>
<tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e25 ">Addr</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e27 "> </td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e29 ">Amt</td>
</tr>
</tbody>
</table>
</td></tr></table>
<div class="section"><p>The join field is <em>Cust</em> which exists in both files. Any
record format name can be specified on the Open Query File (OPNQRYF) command
for the join file. The file does not need a member. The records are not required
to be in keyed sequence.</p>
</div>
<div class="section"><div class="p">You can specify: <pre>OVRDBF FILE(JOINAB) TOFILE(FILEA) SHARE(*YES)
OPNQRYF FILE(FILEA FILEB) FORMAT(JOINAB) +
JFLD((FILEA/CUST FILEB/CUST)) +
MAPFLD((CUST 'FILEA/CUST'))
CALL PGM(PGME) /* Created using file JOINAB as input */
CLOF OPNID(FILEA)
DLTOVR FILE(JOINAB)</pre>
</div>
</div>
<div class="section"><p>File JOINAB is a physical file with no data. This file contains
the record format to be specified on the FORMAT parameter of the OPNQRYF command.</p>
</div>
<div class="section"><p>Notice that the TOFILE parameter on the Override with Database
File (OVRDBF) command specifies the name of the primary file for the join
operation (the first file specified for the FILE parameter on the OPNQRYF
command). In this example, the FILE parameter on the OPNQRYF command identifies
the files in the sequence they are to be joined (A to B). The format for the
file is in the file JOINAB.</p>
</div>
<div class="section"><div class="p">The JFLD parameter identifies the <em>Cust</em> field in FILEA to
join to the <em>Cust</em> field in FILEB. Because the <em>Cust</em> field is not
unique across all of the joined record formats, it must be qualified on the
JFLD parameter. The system attempts to determine, in some cases, the most
efficient values even if you do not specify the JFLD parameter on the OPNQRYF
command. For example, using the previous example, if you specified: <pre>OPNQRYF FILE(FILEA FILEB) FORMAT(JOINAB) +
QRYSLT('FILEA/CUST *EQ FILEB/CUST') +
MAPFLD((CUST 'FILEA/CUST'))</pre>
</div>
</div>
<div class="section"><p>The system joins FILEA and FILEB using the <em>Cust</em> field because
of the values specified for the QRYSLT parameter. Notice that in this example
the JFLD parameter is not specified on the command. However, if either JDFTVAL(*ONLYDFT)
or JDFTVAL(*YES) is specified on the OPNQRYF command, the JFLD parameter must
be specified.</p>
</div>
<div class="section"><div class="p">The MAPFLD parameter is needed on the
Open Query File (OPNQRYF) command to describe which file should be used for
the data for the <em>Cust</em> field in the record format for file JOINAB. If
a field is defined on the MAPFLD parameter, its unqualified name (the <em>Cust</em> field
in this case without the file name identification) can be used anywhere else
in the OPNQRYF command. Because the <em>Cust</em> field is defined on the MAPFLD
parameter, the first value of the JFLD parameter need not be qualified. For
example, the same result can be achieved by specifying: <pre>JFLD((CUST FILEB/CUST)) +
MAPFLD((CUST 'FILEA/CUST'))</pre>
</div>
</div>
<div class="section"><p>Any other uses of the same field name in the OPNQRYF command to
indicate a field from a file other than the file defined by the MAPFLD parameter
must be qualified with a file name.</p>
</div>
<div class="section"><p>Because no KEYFLD parameter is specified, the records appear in
any sequence depending on how the OPNQRYF command selects the records. You
can force the system to arrange the records the same as the primary file.
To do this, specify *FILE on the KEYFLD parameter. You can specify this even
if the primary file is in arrival sequence.</p>
</div>
<div class="section"><p>The JDFTVAL parameter (similar to the JDFTVAL keyword in DDS)
can also be specified on the OPNQRYF command to describe what the system should
do if one of the records is missing from the secondary file. In this example,
the JDFTVAL parameter was not specified, so only the records that exist in
both files are selected.</p>
</div>
<div class="section"><p>If you tell the system to improve the results of the query (through
parameters on the OPNQRYF command), it generally tries to use the file with
the smallest number of records selected as the primary file. However, the
system also tries to avoid building a temporary file.</p>
</div>
<div class="section"><p>You can force the system to follow the file sequence of the join
as you have specified it in the FILE parameter on the OPNQRYF command by
specifying JORDER(*FILE). If JDFTVAL(*YES) or JDFTVAL(*ONLYDFT) is specified,
the system will never change the join file sequence because a different sequence
can cause different results.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafodynjf.htm" title="The dynamic join function allows you to join files without having to first specify data description specifications (DDS) and create a join logical file.">Dynamically join database files without DDS</a></div>
</div>
</div>
</body>
</html>