ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzajp_5.4.0.1/rzajppcticld.htm

97 lines
5.9 KiB
HTML
Raw 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="Use external file descriptions in PL/I applications that use SQL" />
<meta name="abstract" content="You can use the PL/I %INCLUDE directive to include the definitions of externally described files in a source program." />
<meta name="description" content="You can use the PL/I %INCLUDE directive to include the definitions of externally described files in a source program." />
<meta name="DC.subject" content="file description, external, PL/I, external file description, host variable, PL/I program, host variable, externally described, %INCLUDE directive, %INCLUDE directive" />
<meta name="keywords" content="file description, external, PL/I, external file description, host variable, PL/I program, host variable, externally described, %INCLUDE directive, %INCLUDE directive" />
<meta name="DC.Relation" scheme="URI" content="rzajpplone.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="rzajppcticld" />
<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 external file descriptions in PL/I applications that use SQL</title>
</head>
<body id="rzajppcticld"><a name="rzajppcticld"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Use external file descriptions in PL/I applications that use SQL</h1>
<div><p>You can use the PL/I %INCLUDE directive to include the definitions
of externally described files in a source program. </p>
<div class="section"><p>When used with SQL, only a particular format of the %INCLUDE directive
is recognized by the SQL precompiler. That directive format must have the
following three elements or parameter values, otherwise the precompiler ignores
the directive. The required elements are <em>file name, format name,</em> and <em>element
type</em>. There are two optional elements supported by the SQL precompiler:
prefix name and COMMA.</p>
</div>
<div class="section"><p>The structure is ended normally by the last data element of the
record or key structure. However, if in the %INCLUDE directive the COMMA element
is specified, then the structure is not ended.</p>
</div>
<div class="section"><p>To include the definition of the sample table DEPARTMENT described
in <a href="../sqlp/rbafysamptblx.htm"><span class="keyword">DB2<sup>®</sup> UDB for iSeries™</span> sample tables</a> in the DB2 UDB
for <span class="keyword">iSeries</span> SQL Programming
topic collection, you can code: </p>
<pre> DCL 1 TDEPT_STRUCTURE,
%INCLUDE DEPARTMENT(DEPARTMENT,RECORD);</pre>
</div>
<div class="section"><p>In the above example, a host structure named TDEPT_STRUCTURE would
be defined having four fields. The fields would be DEPTNO, DEPTNAME, MGRNO,
and ADMRDEPT.</p>
</div>
<div class="section"><p>For device files, if INDARA was not specified and the file contains
indicators, the declaration cannot be used as a host structure array. The
indicator area is included in the generated structure and causes the storage
to not be contiguous. </p>
<pre>
DCL 1 DEPT_REC(10),
%INCLUDE DEPARTMENT(DEPARTMENT,RECORD);
EXEC SQL <strong>DECLARE</strong> C1 <strong>CURSOR FOR</strong>
<strong>SELECT</strong> * <strong>FROM</strong> CORPDATA.DEPARTMENT;
EXEC SQL <strong>OPEN</strong> C1;
EXEC SQL <strong>FETCH</strong> C1 FOR 10 <strong>ROWS INTO</strong> :DEPT_REC;
</pre>
<div class="note"><span class="notetitle">Note:</span> DATE, TIME, and TIMESTAMP columns will generate host variable
definitions that are treated by SQL with the same comparison and assignment
rules as a DATE, TIME, and TIMESTAMP column. For example, a date host variable
can only be compared with a DATE column or a character string that is a valid
representation of a date.</div>
</div>
<div class="section"><p>Although decimal and zoned fields with precision greater than
15 and binary with nonzero scale fields are mapped to character field variables
in PL/I, SQL considers these fields to be numeric.</p>
</div>
<div class="section"><p>Although GRAPHIC and VARGRAPHIC are mapped to character variables
in PL/I, SQL considers these to be GRAPHIC and VARGRAPHIC host variables.
If the GRAPHIC or VARGRAPHIC column has a UCS-2 CCSID, the generated host
variable will have the UCS-2 CCSID assigned to it. If the GRAPHIC or VARGRAPHIC
column has a UTF-16 CCSID, the generated host variable will have the UTF-16
CCSID assigned to it.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzajpplone.htm" title="This topic describes the unique application and coding requirements for embedding SQL statements in an iSeries PL/I program. Requirements for host structures and host variables are defined.">Code SQL statements in PL/I applications</a></div>
</div>
</div>
</body>
</html>