80 lines
5.0 KiB
HTML
80 lines
5.0 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 host structures in RPG/400 applications that use SQL" />
|
|
<meta name="abstract" content="The RPG/400 data structure name can be used as a host structure name if subfields exist in the data structure. The use of the data structure name in an SQL statement implies the list of subfield names making up the data structure." />
|
|
<meta name="description" content="The RPG/400 data structure name can be used as a host structure name if subfields exist in the data structure. The use of the data structure name in an SQL statement implies the list of subfield names making up the data structure." />
|
|
<meta name="DC.subject" content="RPG/400 program, host structure, declaring, RPG/400, data items, character host variable, character host variables, host variable, character, subfields" />
|
|
<meta name="keywords" content="RPG/400 program, host structure, declaring, RPG/400, data items, character host variable, character host variables, host variable, character, subfields" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajprpg.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="rzajphoststrucrpg" />
|
|
<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 host structures in RPG/400 applications that use SQL</title>
|
|
</head>
|
|
<body id="rzajphoststrucrpg"><a name="rzajphoststrucrpg"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Use host structures in RPG/400 applications that use SQL</h1>
|
|
<div><p>The RPG/400<sup>®</sup> data
|
|
structure name can be used as a <strong>host structure</strong> name if subfields exist
|
|
in the data structure. The use of the data structure name in an SQL statement
|
|
implies the list of subfield names making up the data structure.</p>
|
|
<div class="section"><p>When subfields are not present for the data structure, then the
|
|
data structure name is a host variable of character type. This allows character
|
|
variables larger than 256, because data structures can be up to 9999.</p>
|
|
</div>
|
|
<div class="section"><p>In the following example, BIGCHR is an RPG/400 data structure without subfields.
|
|
SQL treats any referrals to BIGCHR as a character string with a length of
|
|
642. </p>
|
|
<pre>*...1....+....2....+....3....+....4....+....5....+....6....+....7...*
|
|
IBIGCHR DS 642</pre>
|
|
</div>
|
|
<div class="section"><p>In the next example, PEMPL is the name of the host structure consisting
|
|
of the subfields EMPNO, FIRSTN, MIDINT, LASTNAME, and DEPTNO. The referral
|
|
to PEMPL uses the subfields. For example, the first column of EMPLOYEE is
|
|
placed in <em>EMPNO</em>, the second column is placed in <em>FIRSTN</em>, and
|
|
so on. </p>
|
|
<pre> *...1....+....2....+....3....+....4....+....5....+....6....+....7. ..*
|
|
IPEMPL DS
|
|
I 01 06 EMPNO
|
|
I 07 18 FIRSTN
|
|
I 19 19 MIDINT
|
|
I 20 34 LASTNA
|
|
I 35 37 DEPTNO
|
|
…
|
|
C MOVE '000220' EMPNO
|
|
…
|
|
C/EXEC SQL
|
|
C+ <strong>SELECT</strong> * <strong>INTO</strong> :PEMPL
|
|
C+ <strong>FROM</strong> CORPDATA.EMPLOYEE
|
|
C+ <strong>WHERE</strong> EMPNO = :EMPNO
|
|
C/END-EXEC
|
|
</pre>
|
|
</div>
|
|
<div class="section"><p>When writing an SQL statement, referrals to subfields can be qualified.
|
|
Use the name of the data structure, followed by a period and the name of the
|
|
subfield. For example, PEMPL.MIDINT is the same as specifying only MIDINT.</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<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> |