110 lines
5.2 KiB
HTML
110 lines
5.2 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 xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-us">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="dc.language" scheme="rfc1766" 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. -->
|
|
<meta name="dc.date" scheme="iso8601" content="2005-09-19" />
|
|
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
|
|
<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="keywords" content="DECLARE STATEMENT statement, DECLARE STATEMENT,
|
|
SQL statements, names for, for SQL statements, name, identifying by DECLARE,
|
|
prepared SQL statement, in DECLARE STATEMENT statement, statement-name" />
|
|
<title>DECLARE STATEMENT</title>
|
|
<link rel="stylesheet" type="text/css" href="ibmidwb.css" />
|
|
<link rel="stylesheet" type="text/css" href="ic.css" />
|
|
</head>
|
|
<body>
|
|
<a id="Top_Of_Page" name="Top_Of_Page"></a><!-- Java sync-link -->
|
|
<script language = "Javascript" src = "../rzahg/synch.js" type="text/javascript"></script>
|
|
|
|
|
|
<a name="dclst"></a>
|
|
<h2 id="dclst"><a href="rbafzmst02.htm#ToC_995">DECLARE STATEMENT</a></h2><a id="idx2342" name="idx2342"></a><a id="idx2343" name="idx2343"></a><a id="idx2344" name="idx2344"></a><a id="idx2345" name="idx2345"></a><a id="idx2346" name="idx2346"></a>
|
|
<a name="dclar"></a>
|
|
<p id="dclar">The DECLARE STATEMENT statement is used for program documentation.
|
|
It declares names that are used to identify prepared SQL statements.</p>
|
|
<a name="wq1435"></a>
|
|
<h3 id="wq1435"><a href="rbafzmst02.htm#ToC_996">Invocation</a></h3>
|
|
<p>This statement can only be embedded in an application program. It is not
|
|
an executable statement. This statement is not allowed in Java™ or
|
|
REXX.</p>
|
|
<a name="wq1436"></a>
|
|
<h3 id="wq1436"><a href="rbafzmst02.htm#ToC_997">Authorization</a></h3>
|
|
<p>None required.</p>
|
|
<a name="wq1437"></a>
|
|
<h3 id="wq1437"><a href="rbafzmst02.htm#ToC_998">Syntax</a></h3>
|
|
<a href="rbafzmstdclst.htm#synsdstmt"><img src="c.gif" alt="Click to skip syntax diagram" /></a>
|
|
<pre class="cgraphic"><span><img src="c.gif" alt="Read syntax diagram" longdesc="rbafzmstsyn324.htm"
|
|
border="0" /></span><a href="#skipsyn-323"><img src="c.gif" alt="Skip visual syntax diagram"
|
|
border="0" /></a> .-,--------------.
|
|
V |
|
|
>>-DECLARE----<span class="italic">statement-name</span>-+--STATEMENT----------------------><
|
|
|
|
</pre>
|
|
<a name="skipsyn-323" id="skipsyn-323"></a>
|
|
<a name="synsdstmt"></a>
|
|
<h3 id="synsdstmt"><a href="rbafzmst02.htm#ToC_999">Description</a></h3>
|
|
<dl class="parml">
|
|
<dt class="bold"><var class="pv">statement-name</var> </dt><a id="idx2347" name="idx2347"></a>
|
|
<dd>Lists one or more names that are used in your program to identify prepared
|
|
SQL statements.
|
|
</dd>
|
|
</dl>
|
|
<a name="wq1438"></a>
|
|
<h3 id="wq1438"><a href="rbafzmst02.htm#ToC_1000">Example</a></h3>
|
|
<p>This example shows the use of the DECLARE STATEMENT statement in a C program. </p>
|
|
<a name="refdst"></a>
|
|
<pre id="refdst" class="xmp">EXEC SQL <span class="bold">INCLUDE SQLDA</span>;
|
|
void main ()
|
|
{
|
|
EXEC SQL <span class="bold">BEGIN DECLARE SECTION</span> ;
|
|
char src_stmt[32000];
|
|
char sqlda[32000]
|
|
EXEC SQL <span class="bold">END DECLARE SECTION</span> ;
|
|
EXEC SQL INCLUDE SQLCA ;
|
|
|
|
strcpy(src_stmt,"<span class="bold">SELECT</span> DEPTNO, DEPTNAME, MGRNO \
|
|
<span class="bold">FROM</span> DEPARTMENT \
|
|
<span class="bold">WHERE</span> ADMRDEPT = 'A00'");
|
|
|
|
EXEC SQL <span class="bold">DECLARE</span> OBJ_STMT STATEMENT;
|
|
|
|
(Allocate storage from SQLDA)
|
|
|
|
EXEC SQL <span class="bold">DECLARE</span> C1 CURSOR <span class="bold">FOR</span> OBJ_STMT;
|
|
|
|
EXEC SQL <span class="bold">PREPARE</span> OBJ_STMT <span class="bold">FROM</span> :src_stmt;
|
|
EXEC SQL <span class="bold">DESCRIBE</span> OBJ_STMT <span class="bold">INTO</span> :sqlda;
|
|
|
|
(Examine SQLDA) (Set SQLDATA pointer addresses)
|
|
|
|
EXEC SQL <span class="bold">OPEN</span> C1;
|
|
|
|
while (strncmp(SQLSTATE, "00000", 5) )
|
|
{
|
|
EXEC SQL <span class="bold">FETCH</span> C1 <span class="bold">USING</span> <span class="bold">DESCRIPTOR</span> :sqlda;
|
|
|
|
(Print results)
|
|
|
|
}
|
|
|
|
EXEC SQL <span class="bold">CLOSE</span> C1;
|
|
return;
|
|
}
|
|
</pre><a id="idx2348" name="idx2348"></a><a id="idx2349" name="idx2349"></a>
|
|
<hr /><br />
|
|
[ <a href="#Top_Of_Page">Top of Page</a> | <a href="rbafzmstdclpef.htm">Previous Page</a> | <a href="rbafzmstdeclvar.htm">Next Page</a> | <a href="rbafzmst02.htm#wq1">Contents</a> |
|
|
<a href="rbafzmstindex.htm#index">Index</a> ]
|
|
|
|
<a id="Bot_Of_Page" name="Bot_Of_Page"></a>
|
|
</body>
|
|
</html>
|