98 lines
5.8 KiB
HTML
98 lines
5.8 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 structure arrays in ILE RPG applications that use SQL" />
|
|
<meta name="abstract" content="A host structure array is defined as an occurrence data structure or a data structure with the keyword DIM coded. Both types of data structures can be used on the SQL FETCH or INSERT statement when processing multiple rows." />
|
|
<meta name="description" content="A host structure array is defined as an occurrence data structure or a data structure with the keyword DIM coded. Both types of data structures can be used on the SQL FETCH or INSERT statement when processing multiple rows." />
|
|
<meta name="DC.subject" content="arrays of host structures, using arrays, ILE RPG, host structure, using arrays, ILE RPG, ILE RPG program, host structure array, declaring, ILE RPG program, occurrence data structure, FETCH statement, multiple-row, INSERT statement, blocked" />
|
|
<meta name="keywords" content="arrays of host structures, using arrays, ILE RPG, host structure, using arrays, ILE RPG, ILE RPG program, host structure array, declaring, ILE RPG program, occurrence data structure, FETCH statement, multiple-row, INSERT statement, blocked" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajprpgi.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="rzajphostarrayirpg" />
|
|
<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 structure arrays in ILE RPG applications that use SQL</title>
|
|
</head>
|
|
<body id="rzajphostarrayirpg"><a name="rzajphostarrayirpg"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Use host structure arrays in ILE RPG applications that use SQL</h1>
|
|
<div><p>A host structure array is defined as an occurrence data structure
|
|
or a data structure with the keyword DIM coded. Both types of data structures
|
|
can be used on the SQL FETCH or INSERT statement when processing multiple
|
|
rows.</p>
|
|
<div class="section"><p>The following list of items must be considered when using a data
|
|
structure with multiple row blocking support.</p>
|
|
<ul><li>All subfields must be valid host variables.</li>
|
|
<li>All subfields must be contiguous. The first FROM position must be 1 and
|
|
there cannot be overlaps in the TO and FROM positions.</li>
|
|
<li>If the date and time format and separator of date and time subfields within
|
|
the host structure are not the same as the DATFMT, DATSEP, TIMFMT, and TIMSEP
|
|
parameters on the CRTSQLRPGI command (or in the SET OPTION statement), then
|
|
the host structure array is not usable.</li>
|
|
</ul>
|
|
</div>
|
|
<div class="section"><p>For all statements, other than the blocked FETCH and blocked INSERT,
|
|
if an occurrence data structure is used, the current occurrence is used. For
|
|
the blocked FETCH and blocked INSERT, the occurrence is set to 1.</p>
|
|
</div>
|
|
<div class="section"><p>The following example uses a host structure array called DEPARTMENT
|
|
and a blocked FETCH statement to retrieve 10 rows from the DEPARTMENT table.</p>
|
|
<pre>DDEPARTMENT DS OCCURS(10)
|
|
D DEPTNO 01 03A
|
|
D DEPTNM 04 32A
|
|
D MGRNO 33 38A
|
|
D ADMRD 39 41A
|
|
|
|
DIND_ARRAY DS OCCURS(10)
|
|
D INDS 4B 0 DIM(4)
|
|
…
|
|
C/EXEC SQL
|
|
C+ <strong>DECLARE</strong> C1 <strong>CURSOR FOR</strong>
|
|
C+ <strong>SELECT</strong> *
|
|
C+ <strong>FROM</strong> CORPDATA.DEPARTMENT
|
|
C/END-EXEC
|
|
…
|
|
|
|
C/EXEC SQL
|
|
C+ <strong>FETCH</strong> C1 <strong>FOR</strong> 10 <strong>ROWS</strong>
|
|
C+ <strong>INTO</strong> :DEPARTMENT:IND_ARRAY
|
|
C/END-EXEC
|
|
</pre>
|
|
</div>
|
|
<div class="section"><p>Blocked FETCH and blocked INSERT are the only SQL statements that
|
|
allow a data structure with the DIM keyword. A host variable reference with
|
|
a subscript like <em>MyStructure(index).Mysubfield</em> is not supported by
|
|
SQL.</p>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle"><em>Example</em></h4><pre>Dfststruct DS DIM(10) QUALIFIED
|
|
D sub1 4B 0
|
|
D sub2 9B 0
|
|
D sub3 20I 0
|
|
D sub4 9B 0
|
|
|
|
C/EXEC SQL
|
|
C+ FETCH C1 FOR 10 ROWS INTO :fststruct
|
|
C/END-EXEC </pre>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzajprpgi.htm" title="This topic describes the unique application and coding requirements for embedding SQL statements in an ILE RPG program. The coding requirements for host variables are defined.">Code SQL statements in ILE RPG applications</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |