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

117 lines
6.6 KiB
HTML
Raw 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 structures in COBOL applications that use SQL" />
<meta name="abstract" content="A host structure is a named set of host variables that is defined in your program's DATA DIVISION." />
<meta name="description" content="A host structure is a named set of host variables that is defined in your program's DATA DIVISION." />
<meta name="DC.subject" content="COBOL program, host structure, declaring, COBOL" />
<meta name="keywords" content="COBOL program, host structure, declaring, COBOL" />
<meta name="DC.Relation" scheme="URI" content="rzajpcob.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajphoststruccobol.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajphostindicatorcobol.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajphoststrucarraycobol.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajphoststrucappcobol.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajphostarrayindiccobol.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="rzajphoststructurecobol" />
<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 COBOL applications that use SQL</title>
</head>
<body id="rzajphoststructurecobol"><a name="rzajphoststructurecobol"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Use host structures in COBOL applications that use SQL</h1>
<div><p>A <em>host structure</em> is a named set of host variables that is
defined in your program's DATA DIVISION.</p>
<div class="section"><p>Host structures have a maximum of two levels, even though the
host structure might itself occur within a multilevel structure. An exception
is the declaration of a varying-length character string, which requires another
level that must be level 49.</p>
</div>
<div class="section"><p>A host structure name can be a group name whose subordinate levels
name basic data items. For example: </p>
<pre>01 A
02 B
03 C1 PICTURE ...
03 C2 PICTURE ...</pre>
</div>
<div class="section"><p>In this example, B is the name of a host structure consisting
of the basic items C1 and C2.</p>
</div>
<div class="section"><p>When writing an SQL statement using a qualified host variable
name (for example, to identify a field within a structure), use the name of
the structure followed by a period and the name of the field. For example,
specify B.C1 rather than C1 OF B or C1 IN B. However, this guideline applies
only to qualified names within SQL statements; you cannot use this technique
for writing qualified names in COBOL statements.</p>
</div>
<div class="section"><p>A host structure is considered complete if any of the following
items are found: </p>
<ul><li>A COBOL item that must begin in area A</li>
<li>Any SQL statement (except SQL INCLUDE)</li>
</ul>
</div>
<div class="section"><p>After the host structure is defined, you can refer to it in an
SQL statement instead of listing the several host variables (that is, the
names of the data items that comprise the host structure).</p>
</div>
<div class="section"><p>For example, you can retrieve all column values from selected
rows of the table CORPDATA.EMPLOYEE with: </p>
<pre>01 PEMPL.
10 EMPNO PIC X(6).
10 FIRSTNME.
49 FIRSTNME-LEN PIC S9(4) USAGE BINARY.
49 FIRSTNME-TEXT PIC X(12).
10 MIDINIT PIC X(1).
10 LASTNAME.
49 LASTNAME-LEN PIC S9(4) USAGE BINARY.
49 LASTNAME-TEXT PIC X(15).
10 WORKDEPT PIC X(3).
MOVE "000220" TO EMPNO.
EXEC SQL
<strong>SELECT</strong> *
<strong>INTO</strong> :PEMPL
<strong>FROM</strong> CORPDATA.EMPLOYEE
<strong>WHERE</strong> EMPNO = :EMPNO
END-EXEC.</pre>
</div>
<div class="section"><p>Notice that in the declaration of PEMPL, two varying-length string
elements are included in the structure: FIRSTNME and LASTNAME.</p>
</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="rzajphoststruccobol.htm">Host structure in COBOL applications that use SQL</a></strong><br />
The following figure shows the syntax for the valid host structure.</li>
<li class="ulchildlink"><strong><a href="rzajphostindicatorcobol.htm">Host structure indicator array in COBOL applications that use SQL</a></strong><br />
The following figure shows the syntax for valid indicator array declarations.</li>
<li class="ulchildlink"><strong><a href="rzajphoststrucarraycobol.htm">Use host structure arrays in COBOL applications that use SQL</a></strong><br />
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.</li>
<li class="ulchildlink"><strong><a href="rzajphoststrucappcobol.htm">Host structure array in COBOL applications that use SQL</a></strong><br />
The following figures show the syntax for valid host structure array declarations.</li>
<li class="ulchildlink"><strong><a href="rzajphostarrayindiccobol.htm">Host array indicator structure in COBOL applications that use SQL</a></strong><br />
This figure shows the valid syntax for host structure array indicators.</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzajpcob.htm" title="This topic describes the unique application and coding requirements for embedding SQL statements in a COBOL program. Requirements for host structures and host variables are defined.">Code SQL statements in COBOL applications</a></div>
</div>
</div>
</body>
</html>