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

88 lines
6.3 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 PL/I 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 section, 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 section, only the SQLDA form is discussed." />
<meta name="DC.subject" content="application program, SQLDA, PL/I, SQLDA (SQL descriptor area), PL/I program, SQLDA, declaring, dynamic SQL coding, dynamic SQL, coding in PL/I" />
<meta name="keywords" content="application program, SQLDA, PL/I, SQLDA (SQL descriptor area), PL/I program, SQLDA, declaring, dynamic SQL coding, dynamic SQL, coding in PL/I" />
<meta name="DC.Relation" scheme="URI" content="rzajpplone.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="rzajpsqldapli" />
<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 PL/I applications that use SQL</title>
</head>
<body id="rzajpsqldapli"><a name="rzajpsqldapli"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Define SQL descriptor areas in PL/I 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 section, 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>
<p>Unlike the SQLCA, there can be more than one SQLDA in a program, and
an SQLDA can have any valid name. An SQLDA can be coded in a PL/I program
either program directly or by using the SQL INCLUDE statement. Using the SQL
INCLUDE statement requests the inclusion of a standard SQLDA declaration:</p>
<pre>EXEC SQL <strong>INCLUDE SQLDA</strong> ;</pre>
</div>
<div class="section"><p>The included PL/I source statements for the SQLDA are:</p>
<pre>DCL 1 SQLDA BASED(SQLDAPTR),
2 SQLDAID CHAR(8),
2 SQLDABC FIXED(31) BINARY,
2 SQLN FIXED(15) BINARY,
2 SQLD FIXED(15) BINARY,
2 SQLVAR(99),
3 SQLTYPE FIXED(15) BINARY,
3 SQLLEN FIXED(15) BINARY,
3 SQLRES CHAR(12),
3 SQLDATA PTR,
3 SQLIND PTR,
3 SQLNAME CHAR(30) VAR;
DCL SQLDAPTR PTR;</pre>
</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="rzajpplone.htm" title="This topic describes the unique application and coding requirements for embedding SQL statements in an iSeries PL/I program. Requirements for host structures and host variables are defined.">Code SQL statements in PL/I 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>