120 lines
7.7 KiB
HTML
120 lines
7.7 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 ILE RPG 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="SQLDA (SQL descriptor area), ILE RPG, application program, SQLDA, ILE RPG program, SQLDA, declaring, dynamic SQL coding, dynamic SQL, coding in ILE RPG" />
|
||
|
<meta name="keywords" content="SQLDA (SQL descriptor area), ILE RPG, application program, SQLDA, ILE RPG program, SQLDA, declaring, dynamic SQL coding, dynamic SQL, coding in ILE RPG" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="rzajprpgi.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="rzajpsqldairpg" />
|
||
|
<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 ILE RPG applications that use SQL</title>
|
||
|
</head>
|
||
|
<body id="rzajpsqldairpg"><a name="rzajpsqldairpg"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Define SQL descriptor areas in ILE RPG 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>
|
||
|
</div>
|
||
|
<div class="section"><p><img src="./delta.gif" alt="Start of change" />Unlike the SQLCA, there can be more than one
|
||
|
SQLDA in a program and an SQLDA can have any valid name.<img src="./deltaend.gif" alt="End of change" /></p>
|
||
|
<p>Dynamic SQL
|
||
|
is a 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 columns 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 class="section"><p><img src="./delta.gif" alt="Start of change" />You can specify an INCLUDE SQLDA statement in
|
||
|
an ILE RPG program; however, it is not allowed in free format. The format
|
||
|
of the statement is:<img src="./deltaend.gif" alt="End of change" /></p>
|
||
|
<pre>C/EXEC SQL <strong>INCLUDE SQLDA</strong>
|
||
|
C/END-EXEC</pre>
|
||
|
</div>
|
||
|
<div class="section"><p>The INCLUDE SQLDA generates the following data structure.</p>
|
||
|
<pre>D* SQL Descriptor area
|
||
|
D SQLDA DS
|
||
|
D SQLDAID 1 8A
|
||
|
D SQLDABC 9 12B 0
|
||
|
D SQLN 13 14B 0
|
||
|
D SQLD 15 16B 0
|
||
|
D SQL_VAR 80A DIM(SQL_NUM)
|
||
|
D 17 18B 0
|
||
|
D 19 20B 0
|
||
|
D 21 32A
|
||
|
D 33 48*
|
||
|
D 49 64*
|
||
|
D 65 66B 0
|
||
|
D 67 96A
|
||
|
D*
|
||
|
D SQLVAR DS
|
||
|
D SQLTYPE 1 2B 0
|
||
|
D SQLLEN 3 4B 0
|
||
|
D SQLRES 5 16A
|
||
|
D SQLDATA 17 32*
|
||
|
D SQLIND 33 48*
|
||
|
D SQLNAMELEN 49 50B 0
|
||
|
D SQLNAME 51 80A
|
||
|
D* End of SQLDA
|
||
|
</pre>
|
||
|
</div>
|
||
|
<div class="section"><p>The user is responsible for the definition of SQL_NUM. SQL_NUM
|
||
|
must be defined as a numeric constant with the dimension required for SQL_VAR.</p>
|
||
|
</div>
|
||
|
<div class="section"><p>The INCLUDE SQLDA generates two data structures. The second data
|
||
|
structure is used to setup and reference the part of the SQLDA that contains
|
||
|
the field descriptions.</p>
|
||
|
</div>
|
||
|
<div class="section"><p>To set the field descriptions of the SQLDA the program sets up
|
||
|
the field description in the subfields of SQLVAR and then assigns SQLVAR to
|
||
|
SQL_VAR(n), where n is the number of the field in the SQLDA. This is repeated
|
||
|
until all the field descriptions are set.</p>
|
||
|
</div>
|
||
|
<div class="section"><p>When the SQLDA field descriptions are to be referenced the user
|
||
|
assigns SQLVAR(n) to SQL_VAR where n is the number of the field description
|
||
|
to be processed.</p>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div>
|
||
|
<div class="familylinks">
|
||
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzajprpgi.htm" title="This topic describes the unique application and coding requirements for embedding SQL statements in an ILE RPG program. The coding requirements for host variables are defined.">Code SQL statements in ILE RPG 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>
|