100 lines
6.9 KiB
HTML
100 lines
6.9 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="Define SQL descriptor areas in COBOL applications that use SQL" />
|
|
<meta name="abstract" content="There are two types of SQL descriptor areas. One is defined with the ALLOCATE DESCRIPTOR statement. The other is defined using the SQLDA structure. In this topic, only the SQLDA form is discussed." />
|
|
<meta name="description" content="There are two types of SQL descriptor areas. One is defined with the ALLOCATE DESCRIPTOR statement. The other is defined using the SQLDA structure. In this topic, only the SQLDA form is discussed." />
|
|
<meta name="DC.subject" content="SQLDA (SQL descriptor area), COBOL, application program, SQLDA, COBOL program, SQLDA, declaring, dynamic SQL coding, dynamic SQL, coding in COBOL" />
|
|
<meta name="keywords" content="SQLDA (SQL descriptor area), COBOL, application program, SQLDA, COBOL program, SQLDA, declaring, dynamic SQL coding, dynamic SQL, coding in COBOL" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpcob.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../sqlp/rbafydynmic.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../db2/rbafzmstsqldda.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="rzajpsqldacobol" />
|
|
<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>Define SQL descriptor areas in COBOL applications that use SQL</title>
|
|
</head>
|
|
<body id="rzajpsqldacobol"><a name="rzajpsqldacobol"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Define SQL descriptor areas in COBOL applications that use SQL</h1>
|
|
<div><p><span><img src="./delta.gif" alt="Start of change" />There are two types of SQL descriptor areas.
|
|
One is defined with the ALLOCATE DESCRIPTOR statement. The other is defined
|
|
using the SQLDA structure. In this topic, only the SQLDA form is discussed.<img src="./deltaend.gif" alt="End of change" /></span></p>
|
|
<div class="section"><p><img src="./delta.gif" alt="Start of change" />The following statements can use an SQLDA:<img src="./deltaend.gif" alt="End of change" /></p>
|
|
<ul><li>EXECUTE…USING DESCRIPTOR <span class="synph"><span class="var">descriptor-name</span></span></li>
|
|
<li>FETCH…USING DESCRIPTOR <span class="synph"><span class="var">descriptor-name</span></span></li>
|
|
<li>OPEN…USING DESCRIPTOR <span class="synph"><span class="var">descriptor-name</span></span></li>
|
|
<li>CALL…USING DESCRIPTOR <span class="synph"><span class="var">descriptor-name</span></span></li>
|
|
<li>DESCRIBE <span class="synph"><span class="var">statement-name</span></span> INTO <span class="synph"><span class="var">descriptor-name</span></span></li>
|
|
<li><img src="./delta.gif" alt="Start of change" />DESCRIBE INPUT <span class="synph"><span class="var">statement-name</span></span> INTO <span class="synph"><span class="var">descriptor-name</span></span><img src="./deltaend.gif" alt="End of change" /></li>
|
|
<li>DESCRIBE TABLE <span class="synph"><span class="var">host-variable</span></span> INTO <span class="synph"><span class="var">descriptor-name</span></span></li>
|
|
<li>PREPARE <span class="synph"><span class="var">statement-name</span></span> INTO <span class="synph"><span class="var">descriptor-name</span></span></li>
|
|
</ul>
|
|
</div>
|
|
<div class="section"><p>Unlike the SQLCA, there can be more than one SQLDA in a program.
|
|
The SQLDA can have any valid name. An SQLDA can be coded in a COBOL program
|
|
directly or added with the INCLUDE statement. Using the SQL INCLUDE statement
|
|
requests the inclusion of a standard SQLDA declaration: </p>
|
|
<pre>EXEC SQL <strong>INCLUDE SQLDA</strong> END-EXEC.</pre>
|
|
</div>
|
|
<div class="section"><p>The COBOL declarations included for the SQLDA are:</p>
|
|
</div>
|
|
<div class="example"> <div class="fignone"><span class="figcap">Figure 1. INCLUDE SQLDA declarations for COBOL</span><pre>1 SQLDA.
|
|
05 SQLDAID PIC X(8).
|
|
05 SQLDABC PIC S9(9) BINARY.
|
|
05 SQLN PIC S9(4) BINARY.
|
|
05 SQLD PIC S9(4) BINARY.
|
|
05 SQLVAR OCCURS 0 TO 409 TIMES DEPENDING ON SQLD.
|
|
10 SQLTYPE PIC S9(4) BINARY.
|
|
10 SQLLEN PIC S9(4) BINARY.
|
|
10 FILLER REDEFINES SQLLEN.
|
|
15 SQLPRECISION PIC X.
|
|
15 SQLSCALE PIC X.
|
|
10 SQLRES PIC X(12).
|
|
10 SQLDATA POINTER.
|
|
10 SQLIND POINTER.
|
|
10 SQLNAME.
|
|
49 SQLNAMEL PIC S9(4) BINARY.
|
|
49 SQLNAMEC PIC X(30).</pre>
|
|
</div>
|
|
</div>
|
|
<div class="section"><p>SQLDA declarations must appear in the WORKING-STORAGE SECTION
|
|
or LINKAGE SECTION of your program and can be placed wherever a record description
|
|
entry can be specified in those sections. For ILE COBOL for <span class="keyword">iSeries™</span>,
|
|
the SQLDA is declared using the GLOBAL clause.</p>
|
|
</div>
|
|
<div class="section"><p>Dynamic SQL is an advanced programming technique. With
|
|
dynamic SQL, your program can develop and then run SQL statements while the
|
|
program is running. A SELECT statement with a variable SELECT list (that is,
|
|
a list of the data to be returned as part of the query) that runs dynamically
|
|
requires an SQL descriptor area (SQLDA). This is because you cannot know in
|
|
advance how many or what type of variables to allocate in order to receive
|
|
the results of the SELECT.</p>
|
|
</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="relinfo"><strong>Related information</strong><br />
|
|
<div><a href="../sqlp/rbafydynmic.htm">Dynamic SQL applications</a></div>
|
|
<div><a href="../db2/rbafzmstsqldda.htm">SQL descriptor area</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |