97 lines
6.5 KiB
HTML
97 lines
6.5 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="reference" />
|
||
|
<meta name="DC.Title" content="Use external file descriptions in RPG/400 applications that use SQL" />
|
||
|
<meta name="abstract" content="The SQL precompiler processes the RPG/400 source in much the same manner as the ILE RPG compiler. This means that the precompiler processes the /COPY statement for definitions of host variables." />
|
||
|
<meta name="description" content="The SQL precompiler processes the RPG/400 source in much the same manner as the ILE RPG compiler. This means that the precompiler processes the /COPY statement for definitions of host variables." />
|
||
|
<meta name="DC.subject" content="file description, external, RPG/400, external file description, host variable, RPG/400 program, host variable, externally described, /COPY statement, /COPY, command, Override Database File (OVRDBF), used with RPG/400 /COPY, command (CL), Override Database File (OVRDBF), OVRDBF (Override Database File)" />
|
||
|
<meta name="keywords" content="file description, external, RPG/400, external file description, host variable, RPG/400 program, host variable, externally described, /COPY statement, /COPY, command, Override Database File (OVRDBF), used with RPG/400 /COPY, command (CL), Override Database File (OVRDBF), OVRDBF (Override Database File)" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="rzajprpg.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="rzajpexfiledesrpg.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="rzajpexternalfilerpg" />
|
||
|
<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 RPG/400 applications that use SQL</title>
|
||
|
</head>
|
||
|
<body id="rzajpexternalfilerpg"><a name="rzajpexternalfilerpg"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Use external file descriptions in RPG/400 applications that use SQL</h1>
|
||
|
<div><p>The SQL precompiler processes the RPG/400<sup>®</sup> source in much the same manner
|
||
|
as the ILE RPG compiler. This means that the precompiler processes the /COPY
|
||
|
statement for definitions of host variables.</p>
|
||
|
<div class="section"><p>Field definitions for externally described files are obtained
|
||
|
and renamed, if different names are specified. The external definition form
|
||
|
of the data structure can be used to obtain a copy of the column names to
|
||
|
be used as host variables.</p>
|
||
|
</div>
|
||
|
<div class="section"><p>In the following example, the sample table DEPARTMENT is used
|
||
|
as a file in an RPG/400 program.
|
||
|
The SQL precompiler retrieves the field (column) definitions for DEPARTMENT
|
||
|
for use as host variables.</p>
|
||
|
<pre>*...1....+....2....+....3....+....4....+....5....+....6....+....7....*
|
||
|
FTDEPT IP E DISK
|
||
|
F TDEPT KRENAMEDEPTREC
|
||
|
IDEPTREC
|
||
|
I DEPTNAME DEPTN
|
||
|
I ADMRDEPT ADMRD</pre>
|
||
|
<div class="note"><span class="notetitle">Note:</span> Code
|
||
|
an F-spec for a file in your RPG program only if you use RPG/400 statements
|
||
|
to do I/O operations to the file. If you use only SQL statements to do I/O
|
||
|
operations to the file, you can include the external definition by using an
|
||
|
external data structure.</div>
|
||
|
</div>
|
||
|
<div class="section"><p>In the following example, the sample table is specified as an
|
||
|
external data structure. The SQL precompiler retrieves the field (column)
|
||
|
definitions as subfields of the data structure. Subfield names can be used
|
||
|
as host variable names, and the data structure name TDEPT can be used as a
|
||
|
host structure name. The field names must be changed because they are greater
|
||
|
than six characters.</p>
|
||
|
<pre>*...1....+....2....+....3....+....4....+....5....+....6....+....7....*
|
||
|
ITDEPT E DSDEPARTMENT
|
||
|
I DEPTNAME DEPTN
|
||
|
I ADMRDEPT ADMRD</pre>
|
||
|
<div class="note"><span class="notetitle">Note:</span> DATE,
|
||
|
TIME, and TIMESTAMP columns will generate host variable definitions which
|
||
|
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 against a DATE column or a character string which is a valid representation
|
||
|
of a date.</div>
|
||
|
</div>
|
||
|
<div class="section"><p>Although varying-length columns generate fixed-length character-host
|
||
|
variable definitions, to SQL they are varying-length character variables.</p>
|
||
|
</div>
|
||
|
<div class="section"><p>Although GRAPHIC and VARGRAPHIC columns are mapped to character
|
||
|
variables in RPG/400,
|
||
|
SQL considers these GRAPHIC and VARGRAPHIC 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>
|
||
|
<ul class="ullinks">
|
||
|
<li class="ulchildlink"><strong><a href="rzajpexfiledesrpg.htm">External file description considerations for host structure arrays in RPG/400 applications that use SQL</a></strong><br />
|
||
|
Field definitions for externally described files, including renaming of fields, are recognized by the SQL precompiler.</li>
|
||
|
</ul>
|
||
|
|
||
|
<div class="familylinks">
|
||
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzajprpg.htm" title="The RPG/400 licensed program supports both RPG II and RPG III programs.">Code SQL statements in RPG/400 applications</a></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|