116 lines
7.6 KiB
HTML
116 lines
7.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="concept" />
|
|
<meta name="DC.Title" content="Identify which record format to add in a file with multiple formats" />
|
|
<meta name="abstract" content="If your application uses a file name instead of a record format name for records to be added to the database, and if the file used is a logical file with more than one record format, you need to write a format selector program to determine where a record should be placed in the database." />
|
|
<meta name="description" content="If your application uses a file name instead of a record format name for records to be added to the database, and if the file used is a logical file with more than one record format, you need to write a format selector program to determine where a record should be placed in the database." />
|
|
<meta name="DC.subject" content="multiple format logical file, adding records" />
|
|
<meta name="keywords" content="multiple format logical file, adding records" />
|
|
<meta name="DC.Relation" scheme="URI" content="rbafoandbr.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rbafocrlof.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rbafofmtsltu.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="rbafoformt" />
|
|
<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> Identify which record format to add in a file with multiple formats</title>
|
|
</head>
|
|
<body id="rbafoformt"><a name="rbafoformt"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1"> Identify which record format to add in a file with multiple formats</h1>
|
|
<div><p>If your application uses a file name instead of a record format
|
|
name for records to be added to the database, and if the file used is a logical
|
|
file with more than one record format, you need to write a format selector
|
|
program to determine where a record should be placed in the database.</p>
|
|
<div class="p">A format selector can be a control language (CL) program or a high-level
|
|
language program. It must be used if all of the following conditions are true: <ul><li>The logical file is not a join and not a view logical file.</li>
|
|
<li>The logical file is based on multiple physical files.</li>
|
|
<li>The program uses a file name instead of a record format name on the add
|
|
operation.</li>
|
|
</ul>
|
|
</div>
|
|
<div class="p">If you do not write a format selector program for this situation, your
|
|
program ends with an error when it tries to add a record to the database. <div class="note"><span class="notetitle">Note:</span> A
|
|
format selector program cannot be used to select a member if a file has multiple
|
|
members; it can only select a record format.</div>
|
|
</div>
|
|
<p>When an application program wants to add a record to the database file,
|
|
the system calls the format selector program. The format selector program
|
|
examines the record and specifies the record format to be used. The system
|
|
then adds the record to the database file using the specified record format
|
|
name.</p>
|
|
<br /><img src="rbafo542.gif" alt="Example of an application program" /><br /><div class="p">The following example shows the programming statements for a format selector
|
|
program written in the RPG/400<sup>®</sup> language: <pre>CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments+++...
|
|
+++*
|
|
C *ENTRY PLIST
|
|
C PARM RECORD 80
|
|
C* The length of field RECORD must equal the length of
|
|
C* the longest record expected.
|
|
C PARM FORMAT 10
|
|
C MOVELRECORD BYTE 1
|
|
C BYTE IFEQ 'A'
|
|
C MOVEL'HDR' FORMAT
|
|
C ELSE
|
|
C MOVEL'DTL' FORMAT
|
|
C END</pre>
|
|
</div>
|
|
<p>The format selector receives the record in the first parameter; therefore,
|
|
this field must be declared to be the length of the longest record expected
|
|
by the format selector. The format selector can access any portion of the
|
|
record to determine the record format name. In this example, the format selector
|
|
checks the first character in the record for the character A. If the first
|
|
character is A, the format selector moves the record format name HDR into
|
|
the second parameter (FORMAT). If the character is not A, the format selector
|
|
moves the record format name DTL into the second parameter.</p>
|
|
<p>The format selector uses the second parameter, which is a 10-character
|
|
field, to pass the record format name to the system. When the system knows
|
|
the name of the record format, it adds the record to the database.</p>
|
|
<div class="p">You do not need a format selector if: <ul><li>You are doing update operations only. For update operations, your program
|
|
already retrieved the record, and the system knows which physical file the
|
|
record came from.</li>
|
|
<li>Your application program specifies the record format name instead of a
|
|
file name for an add or delete operation.</li>
|
|
<li>All the records used by your application program are contained in one
|
|
physical file.</li>
|
|
</ul>
|
|
</div>
|
|
<p>To create the format selector, you use the create program command for the
|
|
language in which you wrote the program. You cannot specify USRPRF(*OWNER)
|
|
on the create command. The format selector must run under the user's user
|
|
profile not the owner's user profile.</p>
|
|
<p>In addition, for security and integrity and because performance would be
|
|
severely affected, you must not have any calls or input/output operations
|
|
within the format selector.</p>
|
|
<p>The name of the format selector is specified on
|
|
the FMTSLR parameter of the Create Logical File (CRTLF), Change Logical File
|
|
(CHGLF), or Override with Database File (OVRDBF) command. The format selector
|
|
program does not have to exist when the file is created, but it must exist
|
|
when the application program is run.</p>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafoandbr.htm" title="The write operation allows you to add a new record to a physical database file member.">Add database records</a></div>
|
|
</div>
|
|
<div class="relconcepts"><strong>Related concepts</strong><br />
|
|
<div><a href="rbafofmtsltu.htm" title="To add a record to a multiple format logical file, you need to identify the member of the based-on physical file to which you want the record written.">Control how records are added to a file with multiple formats</a></div>
|
|
</div>
|
|
<div class="reltasks"><strong>Related tasks</strong><br />
|
|
<div><a href="rbafocrlof.htm" title="This topic shows how to create a logical file using data description specifications (DDS).">Create a logical file</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |