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

87 lines
4.6 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 COBOL applications that use SQL" />
<meta name="abstract" content="A host structure array is a named set of host variables that is defined in the program's Data Division and has an OCCURS clause." />
<meta name="description" content="A host structure array is a named set of host variables that is defined in the program's Data Division and has an OCCURS clause." />
<meta name="DC.subject" content="COBOL program, host structure, arrays, declaring, using arrays, COBOL, arrays of host structures, using arrays" />
<meta name="keywords" content="COBOL program, host structure, arrays, declaring, using arrays, COBOL, arrays of host structures, using arrays" />
<meta name="DC.Relation" scheme="URI" content="rzajphoststructurecobol.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="rzajphoststrucarraycobol" />
<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 COBOL applications that use SQL</title>
</head>
<body id="rzajphoststrucarraycobol"><a name="rzajphoststrucarraycobol"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Use host structure arrays in COBOL applications that use SQL</h1>
<div><p>A host structure array is a named set of host variables that is
defined in the program's Data Division and has an OCCURS clause. </p>
<div class="section"><p>Host structure arrays have a maximum of two levels, even though
the host structure can occur within a multiple level structure. A varying-length
string requires another level, level 49. A host structure array name can be
a group name whose subordinate levels name basic data items.</p>
</div>
<div class="section"><p>In these examples, the following are true: </p>
<ul><li>All members in B-ARRAY must be valid.</li>
<li>B-ARRAY cannot be qualified.</li>
<li>B-ARRAY can only be used on the blocked form of the FETCH and INSERT statements.</li>
<li>B-ARRAY is the name of an array of host structures containing items C1-VAR
and C2-VAR.</li>
<li>The SYNCHRONIZED attribute must not be specified.</li>
<li>C1-VAR and C2-VAR are not valid host variables in any SQL statement. A
structure cannot contain an intermediate level structure.</li>
</ul>
<pre>01 A-STRUCT.
02 B-ARRAY OCCURS 10 TIMES.
03 C1-VAR PIC X(20).
03 C2-VAR PIC S9(4).
</pre>
</div>
<div class="section"><p>To retrieve 10 rows from the CORPDATA.DEPARTMENT table, use the
following example:</p>
<pre>01 TABLE-1.
02 DEPT OCCURS 10 TIMES.
05 DEPTNO PIC X(3).
05 DEPTNAME.
49 DEPTNAME-LEN PIC S9(4) BINARY.
49 DEPTNAME-TEXT PIC X(29).
05 MGRNO PIC X(6).
05 ADMRDEPT PIC X(3).
01 TABLE-2.
02 IND-ARRAY OCCURS 10 TIMES.
05 INDS PIC S9(4) BINARY OCCURS 4 TIMES.
....
EXEC SQL
<strong>DECLARE</strong> C1 <strong>CURSOR FOR</strong>
<strong>SELECT</strong> *
<strong>FROM</strong> CORPDATA.DEPARTMENT
END-EXEC.
....
EXEC SQL
<strong>FETCH</strong> C1 <strong>FOR</strong> 10 <strong>ROWS INTO</strong> :DEPT :IND-ARRAY
END-EXEC.</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzajphoststructurecobol.htm" title="A host structure is a named set of host variables that is defined in your program's DATA DIVISION.">Use host structures in COBOL applications that use SQL</a></div>
</div>
</div>
</body>
</html>