ibm-information-center/dist/eclipse/plugins/i5OS.ic.cli_5.4.0.1/rzadpfnspcol.htm

255 lines
15 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?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="SQLSpecialColumns - Get special (row identifier) columns" />
<meta name="DC.Relation" scheme="URI" content="rzadphdapi.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1999, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1999, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rzadpfnspcol" />
<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>SQLSpecialColumns</title>
</head>
<body id="rzadpfnspcol"><a name="rzadpfnspcol"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">SQLSpecialColumns - Get special (row identifier) columns</h1>
<div><div class="section"></div>
<div class="section"><h4 class="sectiontitle">Purpose</h4> <p><samp class="codeph">SQLSpecialColumns()</samp> returns
unique row identifier information (primary key or unique index) for a table.
For example, unique index or primary key information. The information is returned
in an SQL result set, which can be retrieved using the same functions that
are used to fetch a result set generated by a SELECT-statement.</p>
</div>
<div class="section"><h4 class="sectiontitle">Syntax</h4><pre>SQLRETURN SQLSpecialColumns (SQLHSTMT hstmt,
SQLSMALLINT fColType,
SQLCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLCHAR *szTableName,
SQLSMALLINT cbTableName,
SQLSMALLINT fScope,
SQLSMALLINT fNullable);</pre>
</div>
<div class="section"><h4 class="sectiontitle">Function arguments</h4>
<div class="tablenoborder"><a name="rzadpfnspcol__tbspcol"><!-- --></a><table cellpadding="4" cellspacing="0" summary="" id="rzadpfnspcol__tbspcol" width="100%" frame="hsides" border="1" rules="all"><caption>Table 1. SQLSpecialColumns arguments</caption><thead align="left"><tr><th align="left" valign="top" width="20%" id="d0e48">Data type</th>
<th align="left" valign="top" width="20%" id="d0e50">Argument</th>
<th align="left" valign="top" width="20%" id="d0e52">Use</th>
<th align="left" valign="top" width="40%" id="d0e54">Description</th>
</tr>
</thead>
<tbody><tr><td align="left" valign="top" width="20%" headers="d0e48 ">SQLCHAR *</td>
<td align="left" valign="top" width="20%" headers="d0e50 "><em>szCatalogName</em></td>
<td align="left" valign="top" width="20%" headers="d0e52 ">Input</td>
<td align="left" valign="top" width="40%" headers="d0e54 ">Catalog qualifier of a three-part table name.
This must be a null pointer or a zero length string.</td>
</tr>
<tr><td align="left" valign="top" width="20%" headers="d0e48 ">SQLCHAR *</td>
<td align="left" valign="top" width="20%" headers="d0e50 "><em>szSchemaName</em></td>
<td align="left" valign="top" width="20%" headers="d0e52 ">Input</td>
<td align="left" valign="top" width="40%" headers="d0e54 ">Schema qualifier of the specified table.</td>
</tr>
<tr><td align="left" valign="top" width="20%" headers="d0e48 ">SQLCHAR *</td>
<td align="left" valign="top" width="20%" headers="d0e50 "><em>szTableName</em></td>
<td align="left" valign="top" width="20%" headers="d0e52 ">Input</td>
<td align="left" valign="top" width="40%" headers="d0e54 ">Table name.</td>
</tr>
<tr><td align="left" valign="top" width="20%" headers="d0e48 ">SQLHSTMT</td>
<td align="left" valign="top" width="20%" headers="d0e50 "><em>hstmt</em></td>
<td align="left" valign="top" width="20%" headers="d0e52 ">Input</td>
<td align="left" valign="top" width="40%" headers="d0e54 ">Statement handle.</td>
</tr>
<tr><td align="left" valign="top" width="20%" headers="d0e48 ">SQLSMALLINT</td>
<td align="left" valign="top" width="20%" headers="d0e50 "><em>cbCatalogName</em></td>
<td align="left" valign="top" width="20%" headers="d0e52 ">Input</td>
<td align="left" valign="top" width="40%" headers="d0e54 ">Length of <em>szCatalogName</em>. This must
be a set to 0.</td>
</tr>
<tr><td align="left" valign="top" width="20%" headers="d0e48 ">SQLSMALLINT</td>
<td align="left" valign="top" width="20%" headers="d0e50 "><em>cbSchemaName</em></td>
<td align="left" valign="top" width="20%" headers="d0e52 ">Input</td>
<td align="left" valign="top" width="40%" headers="d0e54 ">Length of <em>szSchemaName</em>.</td>
</tr>
<tr><td align="left" valign="top" width="20%" headers="d0e48 ">SQLSMALLINT</td>
<td align="left" valign="top" width="20%" headers="d0e50 "><em>cbTableName</em></td>
<td align="left" valign="top" width="20%" headers="d0e52 ">Input</td>
<td align="left" valign="top" width="40%" headers="d0e54 ">Length of <em>cbTableName</em>.</td>
</tr>
<tr><td align="left" valign="top" width="20%" headers="d0e48 ">SQLSMALLINT</td>
<td align="left" valign="top" width="20%" headers="d0e50 "><em>fColType</em></td>
<td align="left" valign="top" width="20%" headers="d0e52 ">Input</td>
<td align="left" valign="top" width="40%" headers="d0e54 ">Reserved for future use to support additional
types of special columns. <p>This data type is currently ignored.</p>
</td>
</tr>
<tr><td align="left" valign="top" width="20%" headers="d0e48 ">SQLSMALLINT</td>
<td align="left" valign="top" width="20%" headers="d0e50 "><em>fNullable</em></td>
<td align="left" valign="top" width="20%" headers="d0e52 ">Input</td>
<td align="left" valign="top" width="40%" headers="d0e54 ">Determines whether to return special columns
that can have a NULL value. <div class="p">Must be one of the following values: <ul><li>SQL_NO_NULLS <p>The row identifier column set returned cannot have any
NULL values.</p>
</li>
<li>SQL_NULLABLE <p>The row identifier column set returned can include columns
where NULL values are permitted.</p>
</li>
</ul>
</div>
</td>
</tr>
<tr><td align="left" valign="top" width="20%" headers="d0e48 ">SQLSMALLINT</td>
<td align="left" valign="top" width="20%" headers="d0e50 "><em>fScope</em></td>
<td align="left" valign="top" width="20%" headers="d0e52 ">Input</td>
<td align="left" valign="top" width="40%" headers="d0e54 ">Minimum required duration for which the unique
row identifier is valid. <div class="p"><em>fScope</em> must be one of the following values:
<ul><li>SQL_SCOPE_CURROW - The row identifier is guaranteed to be valid only while
positioned on that row. A later reselect using the same row identifier values
might not return a row if the row is updated or deleted by another transaction.</li>
<li>SQL_SCOPE_TRANSACTION - The row identifier is guaranteed to be valid for
the duration of the current transaction.</li>
<li>SQL_SCOPE_SESSION - The row identifier is guaranteed to be valid for the
duration of the connection.</li>
</ul>
The duration over which a row identifier value is guaranteed to be valid
depends on the current transaction isolation level. For information and scenarios
involving isolation levels, refer to the IBM<sup>®</sup> DB2<sup>®</sup> <a href="../db2/rbafzmst.htm">SQL Reference</a>.</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section"><h4 class="sectiontitle">Usage</h4><p>If multiple ways exist to uniquely identify
any row in a table (for example, if there are multiple unique indexes on the
specified table), then DB2 UDB CLI returns the <cite>best</cite> set of row
identifier columns based on its internal criterion.</p>
<p>If there is no column
set that allows any row in the table to be uniquely identified, an empty result
set is returned.</p>
<div class="p">The unique row identifier information is returned in
the form of a result set where each column of the row identifier is represented
by one row in the result set. The result set returned by <samp class="codeph">SQLSpecialColumns()</samp> has
the following columns in the following order:
<div class="tablenoborder"><a name="rzadpfnspcol__rsspcol"><!-- --></a><table cellpadding="4" cellspacing="0" summary="" id="rzadpfnspcol__rsspcol" width="100%" frame="hsides" border="1" rules="all"><caption>Table 2. Columns returned by SQLSpecialColumns</caption><thead align="left"><tr><th align="left" valign="top" width="33.33333333333333%" id="d0e228">Column name</th>
<th align="left" valign="top" width="33.33333333333333%" id="d0e230">Data type</th>
<th align="left" valign="top" width="33.33333333333333%" id="d0e232">Description</th>
</tr>
</thead>
<tbody><tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e228 ">SCOPE</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e230 ">SMALLINT not NULL</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e232 ">Actual scope of the rowid. Contains one of
the following values: <ul><li>SQL_SCOPE_CURROW</li>
<li>SQL_SCOPE_TRANSACTION</li>
<li>SQL_SCOPE_SESSION</li>
</ul>
<p>Refer to <em>fScope</em> in <a href="#rzadpfnspcol__tbspcol">Table 1</a> for
a description of each value.</p>
</td>
</tr>
<tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e228 ">COLUMN_NAME</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e230 ">VARCHAR(128) not NULL</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e232 ">Name of the row identifier column.</td>
</tr>
<tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e228 ">DATA_TYPE</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e230 ">SMALLINT not NULL</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e232 ">SQL data type of the column.</td>
</tr>
<tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e228 ">TYPE_NAME</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e230 ">VARCHAR(128) not NULL</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e232 ">Database Management System (DBMS) character
string represented of the name associated with DATA_TYPE column value.</td>
</tr>
<tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e228 ">LENGTH_PRECISION</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e230 ">INTEGER</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e232 ">The precision of the column. NULL is returned
for data types where precision is not applicable.</td>
</tr>
<tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e228 ">BUFFER_LENGTH</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e230 ">INTEGER</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e232 ">The length, in bytes, of the data returned
in the default C type. For CHAR data types, this is the same as the value
in the LENGTH_PRECISION column.</td>
</tr>
<tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e228 ">SCALE</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e230 ">SMALLINT</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e232 ">The scale of the column. NULL is returned
for data types where scale is not applicable.</td>
</tr>
<tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e228 ">PSEUDO_COLUMN</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e230 ">SMALLINT</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e232 ">Indicates whether the column is a pseudo-column; DB2 UDB
CLI only returns: <ul><li>SQL_PC_NOT_PSEUDO</li>
</ul>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="section"><h4 class="sectiontitle">Return codes</h4><ul><li>SQL_SUCCESS</li>
<li>SQL_SUCCESS_WITH_INFO</li>
<li>SQL_ERROR</li>
<li>SQL_INVALID_HANDLE</li>
</ul>
</div>
<div class="section"><h4 class="sectiontitle">Diagnostics</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="hsides" border="1" rules="rows"><caption>Table 3. SQLSpecialColumns SQLSTATEs</caption><thead align="left"><tr><th align="left" valign="top" width="25%" id="d0e339">SQLSTATE</th>
<th align="left" valign="top" width="25%" id="d0e341">Description</th>
<th align="left" valign="top" width="50%" id="d0e343">Explanation</th>
</tr>
</thead>
<tbody><tr><td align="left" valign="top" width="25%" headers="d0e339 "><strong>24</strong>000</td>
<td align="left" valign="top" width="25%" headers="d0e341 ">Cursor state that is not valid</td>
<td align="left" valign="top" width="50%" headers="d0e343 ">Cursor related information is requested,
but no cursor is open.</td>
</tr>
<tr><td align="left" valign="top" width="25%" headers="d0e339 "><strong>40</strong>003 <strong>*</strong></td>
<td align="left" valign="top" width="25%" headers="d0e341 ">Statement completion unknown</td>
<td align="left" valign="top" width="50%" headers="d0e343 ">The communication link between the CLI and
the data source fails before the function completes processing.</td>
</tr>
<tr><td align="left" valign="top" width="25%" headers="d0e339 "><strong>HY</strong>001</td>
<td align="left" valign="top" width="25%" headers="d0e341 ">Memory allocation failure</td>
<td align="left" valign="top" width="50%" headers="d0e343 ">The driver is unable to allocate memory required
to support the processing or completion of the function.</td>
</tr>
<tr><td align="left" valign="top" width="25%" headers="d0e339 "><strong>HY</strong>009</td>
<td align="left" valign="top" width="25%" headers="d0e341 ">Argument length that is not valid</td>
<td align="left" valign="top" width="50%" headers="d0e343 ">The value of one of the length arguments
is less than 0, but not equal to SQL_NTS.</td>
</tr>
<tr><td valign="top" width="25%" headers="d0e339 "><strong>HY</strong>021</td>
<td valign="top" width="25%" headers="d0e341 ">Internal descriptor that is not valid </td>
<td valign="top" width="50%" headers="d0e343 ">The internal descriptor cannot be addressed or allocated,
or it contains a value that is not valid.</td>
</tr>
<tr><td align="left" valign="top" width="25%" headers="d0e339 "><strong>HY</strong>C00</td>
<td align="left" valign="top" width="25%" headers="d0e341 ">Driver not capable</td>
<td align="left" valign="top" width="50%" headers="d0e343 ">The data source does not support the <em>catalog</em> portion
(first part) of a three-part table name.</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzadphdapi.htm" title="This topic provides a description of each CLI function.">DB2 UDB CLI functions</a></div>
</div>
</div>
</body>
</html>