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

83 lines
4.9 KiB
HTML
Raw Permalink 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 host structure arrays in RPG/400 applications that use SQL" />
<meta name="abstract" content="A host structure array is defined as an occurrence data structure. An occurrence data structure can be used on the SQL FETCH statement when fetching multiple rows." />
<meta name="description" content="A host structure array is defined as an occurrence data structure. An occurrence data structure can be used on the SQL FETCH statement when fetching multiple rows." />
<meta name="DC.subject" content="arrays of host structures, using arrays, RPG/400, host structure, RPG/400 program, array, declaring, occurrence data structure, FETCH statement, multiple-row, INSERT statement, blocked" />
<meta name="keywords" content="arrays of host structures, using arrays, RPG/400, host structure, RPG/400 program, array, declaring, occurrence data structure, FETCH statement, multiple-row, INSERT statement, blocked" />
<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="rzajphostarrayrpg" />
<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 RPG/400 applications that use SQL</title>
</head>
<body id="rzajphostarrayrpg"><a name="rzajphostarrayrpg"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Use host structure arrays in RPG/400<sup>®</sup> applications that use SQL</h1>
<div><p>A host structure array is defined as an occurrence data structure.
An occurrence data structure can be used on the SQL FETCH statement when fetching
multiple rows.</p>
<div class="section"><p>In these examples, the following are true: </p>
<ul><li>All items in BARRAY must be valid host variables.</li>
<li>All items in BARRAY must be contiguous. The first FROM position must be
1 and there cannot be overlaps in the TO and FROM positions.</li>
<li>For all statements other than the multiple-row FETCH and blocked INSERT,
if an occurrence data structure is used, the current occurrence is used. For
the multiple-row FETCH and blocked INSERT, the occurrence is set to 1.</li>
</ul>
<pre>*...1....+....2....+....3....+....4....+....5....+....6....+....7. ..*
IBARRAY DS 10
I 01 20 C1VAR
I B 21 220C2VAR
</pre>
</div>
<div class="section"><p>The following example uses a host structure array called DEPT
and a multiple-row FETCH statement to retrieve 10 rows from the DEPARTMENT
table.</p>
<pre> *...1....+....2....+....3....+....4....+....5....+....6....+....7...*
E INDS 4 4 0
IDEPT DS 10
I 01 03 DEPTNO
I 04 32 DEPTNM
I 33 38 MGRNO
I 39 41 ADMRD
IINDARR DS 10
I B 1 80INDS
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>OPEN</strong> C1
C/END-EXEC
C/EXEC SQL
C+ <strong>FETCH</strong> C1 <strong>FOR</strong> 10 <strong>ROWS</strong> <strong>INTO</strong> :DEPT:INDARR
C/END-EXEC</pre>
</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>