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

73 lines
4.5 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 indicator variables in COBOL applications that use SQL" />
<meta name="abstract" content="An indicator variable is a two-byte integer (PIC S9(m) USAGE BINARY, where m is from 1 to 4)." />
<meta name="description" content="An indicator variable is a two-byte integer (PIC S9(m) USAGE BINARY, where m is from 1 to 4)." />
<meta name="DC.subject" content="indicator variable, COBOL, COBOL program, indicator structure, coding requirement, indicator variable, examples, variable declaration, coding SQL statements, application program" />
<meta name="keywords" content="indicator variable, COBOL, COBOL program, indicator structure, coding requirement, indicator variable, examples, variable declaration, coding SQL statements, application program" />
<meta name="DC.Relation" scheme="URI" content="rzajpcob.htm" />
<meta name="DC.Relation" scheme="URI" content="../db2/rbafzmstch2refvar.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="rzajpindicatorcobol" />
<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 indicator variables in COBOL applications that use SQL</title>
</head>
<body id="rzajpindicatorcobol"><a name="rzajpindicatorcobol"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Use indicator variables in COBOL applications that use SQL</h1>
<div><p>An <em>indicator variable</em> is a two-byte integer
(PIC S9(m) USAGE BINARY, where m is from 1 to 4).</p>
<div class="section"><p>You can also specify an indicator structure (defined as an array
of halfword integer variables) to support a host structure. On retrieval,
an indicator variable is used to show whether its associated host variable
has been assigned a null value. On assignment to a column, a negative indicator
variable is used to indicate that a null value should be assigned.</p>
</div>
<div class="section"><p>Indicator variables are declared in the same way as host variables,
and the declarations of the two can be mixed in any way that seems appropriate
to the programmer.</p>
</div>
<div class="section"><h4 class="sectiontitle"><em>Example</em></h4><p>Given the statement:</p>
<pre> EXEC SQL <strong>FETCH</strong> CLS_CURSOR <strong>INTO</strong> :CLS-CD,
:NUMDAY :NUMDAY-IND,
:BGN :BGN-IND,
:ENDCLS :ENDCLS-IND
END-EXEC.</pre>
<p>The variables can be declared as follows:</p>
<pre> EXEC SQL <strong>BEGIN DECLARE SECTION</strong> END-EXEC.
77 CLS-CD PIC X(7).
77 NUMDAY PIC S9(4) BINARY.
77 BGN PIC X(8).
77 ENDCLS PIC X(8).
77 NUMDAY-IND PIC S9(4) BINARY.
77 BGN-IND PIC S9(4) BINARY.
77 ENDCLS-IND PIC S9(4) BINARY.
EXEC SQL <strong>END DECLARE SECTION</strong> END-EXEC.</pre>
</div>
</div>
<div>
<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 class="relref"><strong>Related reference</strong><br />
<div><a href="../db2/rbafzmstch2refvar.htm">References to variables</a></div>
</div>
</div>
</body>
</html>