327 lines
16 KiB
HTML
327 lines
16 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="SET DESCRIPTOR statement, SET DESCRIPTOR,
|
||
|
SQL statements, in SET DESCRIPTOR statement, SQL-descriptor-name, COUNT, DATA,
|
||
|
DATETIME_INTERVAL_CODE, DB2_CCSID, INDICATOR, LENGTH, LEVEL, PRECISION, SCALE,
|
||
|
TYPE, USER_DEFINED_TYPE_CATALOG, USER_DEFINED_TYPE_NAME,
|
||
|
USER_DEFINED_TYPE_SCHEMA, SQL (Structured Query Language), description" />
|
||
|
<title>SET DESCRIPTOR</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="setdescr"></a>
|
||
|
<h2 id="setdescr"><a href="rbafzmst02.htm#ToC_1297">SET DESCRIPTOR</a></h2><a id="idx3130" name="idx3130"></a><a id="idx3131" name="idx3131"></a>
|
||
|
<p>The SET DESCRIPTOR statement sets information in an SQL descriptor.</p>
|
||
|
<a name="wq1748"></a>
|
||
|
<h3 id="wq1748"><a href="rbafzmst02.htm#ToC_1298">Invocation</a></h3>
|
||
|
<p>This statement can only be embedded in an application program,
|
||
|
SQL function, SQL procedure, or trigger. It cannot be issued interactively.
|
||
|
It is an executable statement that cannot be dynamically prepared. It must
|
||
|
not be specified in REXX.</p>
|
||
|
<a name="wq1749"></a>
|
||
|
<h3 id="wq1749"><a href="rbafzmst02.htm#ToC_1299">Authorization</a></h3>
|
||
|
<p>None required.</p>
|
||
|
<a name="wq1750"></a>
|
||
|
<h3 id="wq1750"><a href="rbafzmst02.htm#ToC_1300">Syntax</a></h3>
|
||
|
<a href="rbafzsetdescr.htm#synsetdescr"><img src="c.gif" alt="Click to skip syntax diagram" /></a>
|
||
|
<a name="wq1751"></a>
|
||
|
<div class="fignone" id="wq1751">
|
||
|
<pre class="cgraphic"><span><img src="c.gif" alt="Read syntax diagram" longdesc="rbafzmstsyn381.htm"
|
||
|
border="0" /></span><a href="#skipsyn-380"><img src="c.gif" alt="Skip visual syntax diagram"
|
||
|
border="0" /></a> .-SQL-. .-LOCAL--.
|
||
|
>>-SET--+-----+--DESCRIPTOR--+--------+--<span class="italic">SQL-descriptor-name</span>---->
|
||
|
'-GLOBAL-'
|
||
|
|
||
|
.-,---------------.
|
||
|
V |
|
||
|
>--+---<span class="italic">set-header-info</span>-+----------------------------+----------><
|
||
|
| .-,-------------. |
|
||
|
| V | |
|
||
|
'-VALUE--+-<span class="italic">integer</span>----------+----<span class="italic">set-item-info</span>-+-'
|
||
|
'-<span class="italic">integer-variable</span>-'
|
||
|
|
||
|
</pre>
|
||
|
<a name="skipsyn-380" id="skipsyn-380"></a></div>
|
||
|
<a name="wq1752"></a>
|
||
|
<div class="fignone" id="wq1752">
|
||
|
<pre class="cgraphic"><span><img src="c.gif" alt="Read syntax diagram" longdesc="rbafzmstsyn382.htm"
|
||
|
border="0" /></span><a href="#skipsyn-381"><img src="c.gif" alt="Skip visual syntax diagram"
|
||
|
border="0" /></a>set-header-info:
|
||
|
|
||
|
|--COUNT-- = --+-<span class="italic">constant-1</span>-+-----------------------------------|
|
||
|
'-<span class="italic">variable-1</span>-'
|
||
|
|
||
|
set-item-info:
|
||
|
|
||
|
|--+-DATA----------------------+-- = --+-<span class="italic">constant-2</span>-+-----------|
|
||
|
+-DATETIME_INTERVAL_CODE----+ '-<span class="italic">variable-2</span>-'
|
||
|
+-DB2_CCSID-----------------+
|
||
|
+-INDICATOR-----------------+
|
||
|
+-LENGTH--------------------+
|
||
|
+-LEVEL---------------------+
|
||
|
+-PRECISION-----------------+
|
||
|
+-SCALE---------------------+
|
||
|
+-TYPE----------------------+
|
||
|
+-USER_DEFINED_TYPE_CATALOG-+
|
||
|
+-USER_DEFINED_TYPE_NAME----+
|
||
|
'-USER_DEFINED_TYPE_SCHEMA--'
|
||
|
|
||
|
</pre>
|
||
|
<a name="skipsyn-381" id="skipsyn-381"></a></div>
|
||
|
<a name="synsetdescr"></a>
|
||
|
<h3 id="synsetdescr"><a href="rbafzmst02.htm#ToC_1301">Description</a></h3>
|
||
|
<dl class="parml">
|
||
|
<dt class="bold">LOCAL</dt>
|
||
|
<dd>Specifies the scope of the name of the descriptor to be local to program
|
||
|
invocation. The information provided is set into the descriptor known in this
|
||
|
local scope.
|
||
|
</dd>
|
||
|
<dt class="bold">GLOBAL</dt>
|
||
|
<dd>Specifies the scope of the name of the descriptor to be global to the
|
||
|
SQL session. The information provided is set into the descriptor known to
|
||
|
any program that executes using the same database connection.
|
||
|
</dd>
|
||
|
<dt class="bold"><var class="pv">SQL-descriptor-name</var></dt>
|
||
|
<dd>Names the SQL descriptor. The name must identify a descriptor that already
|
||
|
exists with the specified scope.<a id="idx3132" name="idx3132"></a>
|
||
|
</dd>
|
||
|
<dt class="bold"><var class="pv">set-header-info</var></dt>
|
||
|
<dd>Sets attributes into the SQL descriptor. The same descriptor item must
|
||
|
not be specified more than once in a single SET DESCRIPTOR statement.
|
||
|
</dd>
|
||
|
<dt class="bold">VALUE</dt>
|
||
|
<dd>Specifies the item number for which the specified information is set.
|
||
|
If the item number is greater than the maximum number of items allocated for
|
||
|
the descriptor or the item number is less than 1, an error is returned.
|
||
|
<dl class="parml">
|
||
|
<dt class="bold"><var class="pv">integer</var></dt>
|
||
|
<dd>An integer constant in the range of 1 to the number of items allocated
|
||
|
in the SQL descriptor.
|
||
|
</dd>
|
||
|
<dt class="bold"><var class="pv">integer-variable</var></dt>
|
||
|
<dd>Identifies a variable declared in the program in accordance
|
||
|
with the rules for declaring variables. The data type of the variable must
|
||
|
be SMALLINT, INTEGER, BIGINT, or DECIMAL or NUMERIC with a scale of zero.
|
||
|
The value of variable must be in the range of 1 to the maximum number of items
|
||
|
allocated in the SQL descriptor.
|
||
|
</dd>
|
||
|
</dl>
|
||
|
</dd>
|
||
|
<dt class="bold"><var class="pv">set-item-info</var></dt>
|
||
|
<dd>Sets information about a specific item into the SQL descriptor. The
|
||
|
same descriptor item must not be specified more than once in a single SET
|
||
|
DESCRIPTOR statement. Items that are not applicable to the specified type
|
||
|
are ignored.
|
||
|
</dd>
|
||
|
</dl>
|
||
|
<a name="sethdrinfo"></a>
|
||
|
<h4 id="sethdrinfo"><span><var class="pv">set-header-info</var></span></h4>
|
||
|
<p></p>
|
||
|
<dl class="parml">
|
||
|
<dt class="bold">COUNT</dt><a id="idx3133" name="idx3133"></a>
|
||
|
<dd>A count of the number of items that will be specified in the descriptor.
|
||
|
</dd>
|
||
|
<dt class="bold"><var class="pv">variable–1</var></dt>
|
||
|
<dd>Identifies a variable declared in the program in accordance
|
||
|
with the rules for declaring variables, but must not be a file reference variable.
|
||
|
The data type of the variable must be compatible with the COUNT header item
|
||
|
as specified in <a href="rbafzgetdescr.htm#getdesctable">Table 56</a>. The variable is assigned (using
|
||
|
storage assignment rules) to the COUNT header item. For details on the assignment
|
||
|
rules, see <a href="rbafzmstch2bas.htm#ch2bas">Assignments and comparisons</a>.
|
||
|
</dd>
|
||
|
<dt class="bold"><var class="pv">constant–1</var></dt>
|
||
|
<dd>Identifies a constant value used to set the COUNT header
|
||
|
item. The data type of the constant must be compatible with the COUNT header
|
||
|
item as specified in <a href="rbafzgetdescr.htm#getdesctable">Table 56</a>. The constant is assigned
|
||
|
(using storage assignment rules) to the COUNT header item. For details on
|
||
|
the assignment rules, see <a href="rbafzmstch2bas.htm#ch2bas">Assignments and comparisons</a>.
|
||
|
</dd>
|
||
|
</dl>
|
||
|
<a name="setiteminfo"></a>
|
||
|
<h4 id="setiteminfo"><span><var class="pv">set-item-info</var></span></h4>
|
||
|
<p></p>
|
||
|
<dl class="parml">
|
||
|
<dt class="bold">DATA</dt><a id="idx3134" name="idx3134"></a>
|
||
|
<dd>Specifies the value for the data described by the item descriptor. If
|
||
|
the value of INDICATOR is negative, then the value of DATA is undefined. The
|
||
|
assigned value cannot be a constant.
|
||
|
</dd>
|
||
|
<dt class="bold">DATETIME_INTERVAL_CODE</dt><a id="idx3135" name="idx3135"></a>
|
||
|
<dd>Specifies the specific datetime data type. DATETIME_INTERVAL_CODE
|
||
|
must be specified if TYPE is set to 9.
|
||
|
<dl>
|
||
|
<dt class="bold">1</dt>
|
||
|
<dd>DATE
|
||
|
</dd>
|
||
|
<dt class="bold">2</dt>
|
||
|
<dd>TIME
|
||
|
</dd>
|
||
|
<dt class="bold">3</dt>
|
||
|
<dd>TIMESTAMP
|
||
|
</dd>
|
||
|
</dl>
|
||
|
</dd>
|
||
|
<dt class="bold">DB2_CCSID</dt><a id="idx3136" name="idx3136"></a>
|
||
|
<dd>Specifies the CCSID of character, graphic, or datetime data.
|
||
|
The value is not applicable for all other data types. If the DB2_CCSID is
|
||
|
not specified or 0 is specified, the CCSID of the variable will be determined
|
||
|
by the CCSID of the job.
|
||
|
</dd>
|
||
|
<dt class="bold">INDICATOR</dt><a id="idx3137" name="idx3137"></a>
|
||
|
<dd>Specifies the value for the indicator. A negative value indicates the
|
||
|
value described by this descriptor item is the null value. A non-negative
|
||
|
indicates a DATA value will be provided for this descriptor item. If not set,
|
||
|
the value of INDICATOR is 0.
|
||
|
</dd>
|
||
|
<dt class="bold">LENGTH</dt><a id="idx3138" name="idx3138"></a>
|
||
|
<dd>Specifies the maximum length of the data. If the data type is a character
|
||
|
or graphic string type or a datetime type, the length represents the number
|
||
|
of characters (not bytes). If the data type is a binary string or any other
|
||
|
type, the length represents the number of bytes. If LENGTH is not specified,
|
||
|
a default length will be used. For a description of the defaults, see <a href="rbafzsetdescr.htm#setdescdefaults">Table 75</a>.
|
||
|
</dd>
|
||
|
<dt class="bold">LEVEL</dt><a id="idx3139" name="idx3139"></a>
|
||
|
<dd>The level of the item descriptor. If specified, the value must be 0.
|
||
|
</dd>
|
||
|
<dt class="bold">PRECISION</dt><a id="idx3140" name="idx3140"></a>
|
||
|
<dd>Specifies the precision for descriptor items of data type
|
||
|
DECIMAL, NUMERIC, DOUBLE, REAL, and FLOAT. If PRECISION is not specified,
|
||
|
a default precision will be used. For a description of the defaults, see <a href="rbafzsetdescr.htm#setdescdefaults">Table 75</a>.
|
||
|
</dd>
|
||
|
<dt class="bold">SCALE</dt><a id="idx3141" name="idx3141"></a>
|
||
|
<dd>Specifies the scale for descriptor items of data type DECIMAL or NUMERIC.
|
||
|
If SCALE is not specified, a default scale will be used. For a description
|
||
|
of the defaults, see <a href="rbafzsetdescr.htm#setdescdefaults">Table 75</a>.
|
||
|
</dd>
|
||
|
<dt class="bold">TYPE</dt><a id="idx3142" name="idx3142"></a>
|
||
|
<dd>Specifies a data type code representing the data type of the descriptor
|
||
|
item. For a description of the data type codes and lengths, see <a href="rbafzgetdescr.htm#datatypecode">Table 57</a>.
|
||
|
Either TYPE or USER_DEFINED_TYPE_NAME and USER_DEFINED_TYPE_SCHEMA (but not
|
||
|
both) must be specified for each descriptor item.
|
||
|
</dd>
|
||
|
<dt class="bold">USER_DEFINED_TYPE_CATALOG</dt><a id="idx3143" name="idx3143"></a>
|
||
|
<dd>Specifies the server name of the user-defined type. If USER_DEFINED_TYPE_CATALOG
|
||
|
is specified, it must be equal to the current server. Otherwise, the USER_DEFINED_TYPE_CATALOG
|
||
|
is the current server.
|
||
|
</dd>
|
||
|
<dt class="bold">USER_DEFINED_TYPE_NAME</dt><a id="idx3144" name="idx3144"></a>
|
||
|
<dd>Specifies the name of the user-defined data type. Either
|
||
|
TYPE or USER_DEFINED_TYPE_NAME and USER_DEFINED_TYPE_SCHEMA (but not both)
|
||
|
must be specified for each descriptor item.
|
||
|
</dd>
|
||
|
<dt class="bold">USER_DEFINED_TYPE_SCHEMA </dt><a id="idx3145" name="idx3145"></a>
|
||
|
<dd>Specifies the schema containing the user-defined type. Either
|
||
|
TYPE or USER_DEFINED_TYPE_NAME and USER_DEFINED_TYPE_SCHEMA (but not both)
|
||
|
must be specified for each descriptor item.
|
||
|
</dd>
|
||
|
<dt class="bold"><var class="pv">variable–2</var></dt>
|
||
|
<dd>Identifies a variable declared in the program in accordance
|
||
|
with the rules for declaring variables, but must not be a file reference variable.
|
||
|
The data type of the variable must be compatible with the descriptor information
|
||
|
item as specified in <a href="rbafzgetdescr.htm#getdesctable">Table 56</a>. The variable is assigned
|
||
|
(using storage assignment rules) to the corresponding descriptor item. For
|
||
|
details on the assignment rules, see <a href="rbafzmstch2bas.htm#ch2bas">Assignments and comparisons</a>.
|
||
|
<p>When setting the DATA item, in general the variable must have the same data
|
||
|
type, length, precision, scale, and CCSID as specified in <a href="rbafzgetdescr.htm#getdesctable">Table 56</a>.
|
||
|
For variable-length types, the variable length must not be less than the
|
||
|
LENGTH in the descriptor. For C nul-terminated types, the variable length
|
||
|
must be at least one greater than the LENGTH in the descriptor.</p>
|
||
|
</dd>
|
||
|
<dt class="bold"><var class="pv">constant-2</var></dt>
|
||
|
<dd>Identifies a constant value used to set the descriptor item.
|
||
|
The data type of the constant must have the same data type, length, precision,
|
||
|
scale, and CCSID as specified in <a href="rbafzgetdescr.htm#getdesctable">Table 56</a>. The constant
|
||
|
is assigned (using storage assignment rules) to the corresponding descriptor
|
||
|
item. For details on the assignment rules, see <a href="rbafzmstch2bas.htm#ch2bas">Assignments and comparisons</a>.
|
||
|
<p>If
|
||
|
the descriptor item to be set is DATA, <var class="pv">constant-2</var> cannot be specified.</p>
|
||
|
</dd>
|
||
|
</dl>
|
||
|
<a name="wq1753"></a>
|
||
|
<h3 id="wq1753"><a href="rbafzmst02.htm#ToC_1304">Notes</a></h3>
|
||
|
<p><span class="bold">Default values for descriptor items:</span> The following
|
||
|
table represents the default values for LENGTH, PRECISION, and SCALE, if they
|
||
|
are not specified for a descriptor item.</p>
|
||
|
<a name="setdescdefaults"></a>
|
||
|
<table id="setdescdefaults" width="100%" summary="" border="1" frame="border" rules="all">
|
||
|
<caption>Table 75. Default LENGTH, PRECISION, and SCALE</caption>
|
||
|
<thead valign="bottom">
|
||
|
<tr>
|
||
|
<th id="wq1754" width="50%" align="left" valign="bottom">Data Type</th>
|
||
|
<th id="wq1755" width="16%" align="left" valign="bottom">LENGTH</th>
|
||
|
<th id="wq1756" width="16%" align="left">PRECISION</th>
|
||
|
<th id="wq1757" width="16%" align="left">SCALE</th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody valign="top">
|
||
|
<tr>
|
||
|
<td headers="wq1754">DECIMAL and NUMERIC</td>
|
||
|
<td headers="wq1755"></td>
|
||
|
<td headers="wq1756">5</td>
|
||
|
<td headers="wq1757">0</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td headers="wq1754">FLOAT</td>
|
||
|
<td headers="wq1755"></td>
|
||
|
<td headers="wq1756">53</td>
|
||
|
<td headers="wq1757">0</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td headers="wq1754">CHARACTER, VARCHAR, and CLOB</td>
|
||
|
<td headers="wq1755">1</td>
|
||
|
<td headers="wq1756"></td>
|
||
|
<td headers="wq1757"></td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td headers="wq1754">GRAPHIC, VARGRAPHIC, and DBCLOB</td>
|
||
|
<td headers="wq1755">1</td>
|
||
|
<td headers="wq1756"></td>
|
||
|
<td headers="wq1757"></td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td headers="wq1754">BINARY, VARBINARY, and BLOB</td>
|
||
|
<td headers="wq1755">1</td>
|
||
|
<td headers="wq1756"></td>
|
||
|
<td headers="wq1757"></td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
<a name="wq1758"></a>
|
||
|
<h3 id="wq1758"><a href="rbafzmst02.htm#ToC_1305">Example</a></h3>
|
||
|
<p><span class="italic">Example 1:</span> Set the number of items in descriptor
|
||
|
'NEWDA' to the value in :numitems.</p>
|
||
|
<pre class="xmp"> EXEC SQL <span class="bold">SET DESCRIPTOR</span> 'NEWDA'
|
||
|
<span class="bold">COUNT =</span> :numitems<span class="bold">;</span>
|
||
|
</pre>
|
||
|
<p><span class="italic">Example 2:</span> Set the value of the type and
|
||
|
length for the first item descriptor of descriptor 'NEWDA'</p>
|
||
|
<pre class="xmp"> <span class="bold">SET DESCRIPTOR</span> 'NEWDA'
|
||
|
<span class="bold">VALUE</span> 1 <span class="bold">TYPE =</span> :dtype,
|
||
|
<span class="bold">LENGTH =</span> :olength<span class="bold">;</span></pre><a id="idx3146" name="idx3146"></a><a id="idx3147" name="idx3147"></a><a id="idx3148" name="idx3148"></a><a id="idx3149" name="idx3149"></a>
|
||
|
<hr /><br />
|
||
|
[ <a href="#Top_Of_Page">Top of Page</a> | <a href="rbafzsetdegree.htm">Previous Page</a> | <a href="rbafzmstsetep.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>
|