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

76 lines
4.6 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="reference" />
<meta name="DC.Title" content="Example 3: Define fields derived from existing field definitions" />
<meta name="abstract" content="This example shows the use of derived fields and built-in functions." />
<meta name="description" content="This example shows the use of derived fields and built-in functions." />
<meta name="DC.Relation" scheme="URI" content="rbafofdefd.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="rbafofdefdex3" />
<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 3: Define fields derived from existing field definitions</title>
</head>
<body id="rbafofdefdex3"><a name="rbafofdefdex3"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example 3: Define fields derived from existing field definitions</h1>
<div><p>This example shows the use of derived fields and built-in functions.</p>
<div class="section"><div class="p">Assume, in the previous example, that a field called <em>Fldx</em> also
exists in FILEA, and the <em>Fldx</em> field has appropriate attributes used
to hold the sine of the <em>Fldm</em> field. Also assume that you are not using
the contents of the <em>Fldx</em> field. You can use the MAPFLD parameter to
change the contents of a field before passing it to your high-level language
program. For example, you can specify: <pre>OVRDBF FILE(FILEA) SHARE(*YES)
OPNQRYF FILE(FILEA) MAPFLD((FLDX '%SIN(FLDM)'))
CALL PGM(PGMF) /* Created using file FILEA as input */
CLOF OPNID(FILEA)
DLTOVR FILE(FILEA)</pre>
</div>
</div>
<div class="section"><p>In this case, you do not need to specify a different record format
on the FORMAT parameter. (The default uses the format of the first file on
the FILE parameter.) Therefore, the program is created by using FILEA. When
using this technique, you must ensure that the field you redefine has attributes
that allow the calculated value to process correctly. The least complicated
approach is to create a separate file with the specific fields you want to
process for each query.</p>
</div>
<div class="section"><p>You can also use this technique with a mapped field definition
and the %XLATE function to translate a field so that it appears to the program
in a different manner than what exists in the database. For example, you can
translate a lowercase field so the program only sees uppercase.</p>
</div>
<div class="section"><div class="p">The sort sequence and language identifier can affect the results
of the %MIN and %MAX built-in functions. For example, the uppercase and lowercase
versions of letters can be equal or unequal depending on the selected sort
sequence and language identifier. <div class="note"><span class="notetitle">Note:</span> The translated field value is used
to determine the minimum and maximum, but the untranslated value is returned
in the result record.</div>
</div>
</div>
<div class="section"><p>The example described uses FILEA as an input file. You can also
update data using the Open Query File (OPNQRYF) command. However, if you use
a mapped field definition to change a field, updates to the field are ignored.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafofdefd.htm" title="Listed here are the operations allowed by defining fields derived from existing field definitions.">Define fields derived from existing field definitions</a></div>
</div>
</div>
</body>
</html>