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

219 lines
14 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="SQLDescribeCol - Describe column attributes" />
<meta name="DC.Relation" scheme="URI" content="rzadphdapi.htm" />
<meta name="DC.Relation" scheme="URI" content="rzadpfncolat.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="rzadpfndecol" />
<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>SQLDescribeCol</title>
</head>
<body id="rzadpfndecol"><a name="rzadpfndecol"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">SQLDescribeCol - Describe column attributes</h1>
<div><div class="section"></div>
<div class="section"><h4 class="sectiontitle">Purpose</h4> <p><samp class="codeph">SQLDescribeCol()</samp> returns
the result descriptor information (column name, type, precision) for the indicated
column in the result set generated by a SELECT statement.</p>
<p>If the application
only needs one attribute of the descriptor information, the <samp class="codeph">SQLColAttributes()</samp> function
can be used in place of <samp class="codeph">SQLDescribeCol()</samp>. </p>
<p>Either <samp class="codeph">SQLPrepare()</samp> or <samp class="codeph">SQLExecDirect()</samp> must
be called before calling this function.</p>
<p>This function (or <samp class="codeph">SQLColAttributes()</samp>)
is typically called before <samp class="codeph">SQLBindCol()</samp>.</p>
</div>
<div class="section"><h4 class="sectiontitle">Syntax</h4><pre>SQLRETURN SQLDescribeCol (SQLHSTMT hstmt,
SQLSMALLINT icol,
SQLCHAR *szColName,
SQLSMALLINT cbColNameMax,
SQLSMALLINT *pcbColName,
SQLSMALLINT *pfSqlType,
SQLINTEGER *pcbColDef,
SQLSMALLINT *pibScale,
SQLSMALLINT *pfNullable);</pre>
</div>
<div class="section"><h4 class="sectiontitle">Function arguments</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="hsides" border="1" rules="all"><caption>Table 1. SQLDescribeCol arguments</caption><thead align="left"><tr><th align="left" valign="bottom" width="21.296296296296298%" id="d0e75">Data type</th>
<th align="left" valign="bottom" width="23.703703703703706%" id="d0e77">Argument</th>
<th align="left" valign="bottom" width="14.814814814814813%" id="d0e79">Use</th>
<th align="left" valign="bottom" width="40.18518518518518%" id="d0e81">Description</th>
</tr>
</thead>
<tbody><tr><td align="left" valign="top" width="21.296296296296298%" headers="d0e75 ">SQLCHAR *</td>
<td align="left" valign="top" width="23.703703703703706%" headers="d0e77 "><em>szColName</em></td>
<td align="left" valign="top" width="14.814814814814813%" headers="d0e79 ">Output</td>
<td align="left" valign="top" width="40.18518518518518%" headers="d0e81 ">Pointer to column name buffer.</td>
</tr>
<tr><td align="left" valign="top" width="21.296296296296298%" headers="d0e75 ">SQLHSTMT</td>
<td align="left" valign="top" width="23.703703703703706%" headers="d0e77 "><em>hstmt</em></td>
<td align="left" valign="top" width="14.814814814814813%" headers="d0e79 ">Input</td>
<td align="left" valign="top" width="40.18518518518518%" headers="d0e81 ">Statement handle.</td>
</tr>
<tr><td align="left" valign="top" width="21.296296296296298%" headers="d0e75 ">SQLINTEGER *</td>
<td align="left" valign="top" width="23.703703703703706%" headers="d0e77 "><em>pcbColDef</em></td>
<td align="left" valign="top" width="14.814814814814813%" headers="d0e79 ">Output</td>
<td align="left" valign="top" width="40.18518518518518%" headers="d0e81 ">Precision of column as defined in the database.
<p>If <em>fSqlType</em> denotes a graphic SQL data type, then this variable
indicates the maximum number of double-byte <em>characters</em> the column can
hold.</p>
</td>
</tr>
<tr><td align="left" valign="top" width="21.296296296296298%" headers="d0e75 ">SQLSMALLINT *</td>
<td align="left" valign="top" width="23.703703703703706%" headers="d0e77 "><em>pcbColName</em></td>
<td align="left" valign="top" width="14.814814814814813%" headers="d0e79 ">Output</td>
<td align="left" valign="top" width="40.18518518518518%" headers="d0e81 ">Bytes available to return for <em>szColName</em> argument.
Truncation of column name (<em>szColName</em>) to <em>cbColNameMax - 1</em> bytes
occurs if <em>pcbColName</em> is greater than or equal to <em>cbColNameMax</em>.</td>
</tr>
<tr><td align="left" valign="top" width="21.296296296296298%" headers="d0e75 ">SQLSMALLINT *</td>
<td align="left" valign="top" width="23.703703703703706%" headers="d0e77 "><em>pfNullable</em></td>
<td align="left" valign="top" width="14.814814814814813%" headers="d0e79 ">Output</td>
<td align="left" valign="top" width="40.18518518518518%" headers="d0e81 ">Indicates whether NULLS are allowed for this
column <ul><li>SQL_NO_NULLS.</li>
<li>SQL_NULLABLE.</li>
</ul>
</td>
</tr>
<tr><td align="left" valign="top" width="21.296296296296298%" headers="d0e75 ">SQLSMALLINT *</td>
<td align="left" valign="top" width="23.703703703703706%" headers="d0e77 "><em>pfSqlType</em></td>
<td align="left" valign="top" width="14.814814814814813%" headers="d0e79 ">Output</td>
<td align="left" valign="top" width="40.18518518518518%" headers="d0e81 ">SQL data type of column.</td>
</tr>
<tr><td align="left" valign="top" width="21.296296296296298%" headers="d0e75 ">SQLSMALLINT *</td>
<td align="left" valign="top" width="23.703703703703706%" headers="d0e77 "><em>pibScale</em></td>
<td align="left" valign="top" width="14.814814814814813%" headers="d0e79 ">Output</td>
<td align="left" valign="top" width="40.18518518518518%" headers="d0e81 ">Scale of column as defined in the database
(only applies to SQL_DECIMAL, SQL_NUMERIC, SQL_TIMESTAMP).</td>
</tr>
<tr><td align="left" valign="top" width="21.296296296296298%" headers="d0e75 ">SQLSMALLINT</td>
<td align="left" valign="top" width="23.703703703703706%" headers="d0e77 "><em>cbColNameMax</em></td>
<td align="left" valign="top" width="14.814814814814813%" headers="d0e79 ">Input</td>
<td align="left" valign="top" width="40.18518518518518%" headers="d0e81 ">Size of <em>szColName</em> buffer.</td>
</tr>
<tr><td align="left" valign="top" width="21.296296296296298%" headers="d0e75 ">SQLSMALLINT</td>
<td align="left" valign="top" width="23.703703703703706%" headers="d0e77 "><em>icol</em></td>
<td align="left" valign="top" width="14.814814814814813%" headers="d0e79 ">Input</td>
<td align="left" valign="top" width="40.18518518518518%" headers="d0e81 ">Column number to be described.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section"><h4 class="sectiontitle">Usage</h4><p>Columns are identified by a number and are
numbered sequentially from left to right starting with 1, and can be described
in any order.</p>
<p>A valid pointer and buffer space must be made available
for the <em>szColName</em> argument. If a null pointer is specified for any
of the remaining pointer arguments, DB2<sup>®</sup> UDB CLI assumes that the information
is not needed by the application and nothing is returned.</p>
</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="p">If <samp class="codeph">SQLDescribeCol()</samp> returns
either SQL_ERROR, or SQL_SUCCESS_WITH_INFO, one of the following SQLSTATEs
can be obtained by calling the <samp class="codeph">SQLError()</samp> function.
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="hsides" border="1" rules="rows"><caption>Table 2. SQLDescribeCol SQLSTATEs</caption><thead align="left"><tr><th align="left" valign="top" width="25%" id="d0e253">SQLSTATE</th>
<th align="left" valign="top" width="25%" id="d0e255">Description</th>
<th align="left" valign="top" width="50%" id="d0e257">Explanation</th>
</tr>
</thead>
<tbody><tr><td align="left" valign="top" width="25%" headers="d0e253 "><strong>01</strong>004</td>
<td align="left" valign="top" width="25%" headers="d0e255 ">Data truncated</td>
<td align="left" valign="top" width="50%" headers="d0e257 ">The column name returned in the argument <em>szColName</em> is
longer than the value specified in the argument <em>cbColNameMax</em>. The argument <em>pcbColName</em> contains
the length of the full column name. (Function returns SQL_SUCCESS_WITH_INFO.)</td>
</tr>
<tr><td align="left" valign="top" width="25%" headers="d0e253 "><strong>07</strong>005 <strong>*</strong></td>
<td align="left" valign="top" width="25%" headers="d0e255 ">Not a SELECT statement</td>
<td align="left" valign="top" width="50%" headers="d0e257 ">The statement associated with the <em>hstmt</em> did
not return a result set. There were no columns to describe. (Call <samp class="codeph">SQLNumResultCols()</samp> first
to determine if there are any rows in the result set.)</td>
</tr>
<tr><td align="left" valign="top" width="25%" headers="d0e253 "><strong>07</strong>009</td>
<td align="left" valign="top" width="25%" headers="d0e255 ">Column number that is not valid</td>
<td align="left" valign="top" width="50%" headers="d0e257 ">The value specified for the argument <em>icol</em> is
less than 1. <p>The value specified for the argument <em>icol</em> is greater
than the number of columns in the result set.</p>
</td>
</tr>
<tr><td align="left" valign="top" width="25%" headers="d0e253 "><strong>40</strong>003 <strong>*</strong></td>
<td align="left" valign="top" width="25%" headers="d0e255 ">Statement completion unknown</td>
<td align="left" valign="top" width="50%" headers="d0e257 ">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="d0e253 "><strong>58</strong>004</td>
<td align="left" valign="top" width="25%" headers="d0e255 ">System error</td>
<td align="left" valign="top" width="50%" headers="d0e257 ">Unrecoverable system error.</td>
</tr>
<tr><td align="left" valign="top" width="25%" headers="d0e253 "><strong>HY</strong>001</td>
<td align="left" valign="top" width="25%" headers="d0e255 ">Memory allocation failure</td>
<td align="left" valign="top" width="50%" headers="d0e257 ">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="d0e253 "><strong>HY</strong>009</td>
<td align="left" valign="top" width="25%" headers="d0e255 ">Argument value that is not valid</td>
<td align="left" valign="top" width="50%" headers="d0e257 ">The length specified in argument <em>cbColNameMax</em> is
less than 1. <p>The argument <em>szColName</em> or <em>pcbColName</em> is a null
pointer.</p>
</td>
</tr>
<tr><td align="left" valign="top" width="25%" headers="d0e253 "><strong>HY</strong>010</td>
<td align="left" valign="top" width="25%" headers="d0e255 ">Function sequence error</td>
<td align="left" valign="top" width="50%" headers="d0e257 ">The function is called before calling <samp class="codeph">SQLPrepare()</samp> or <samp class="codeph">SQLExecDirect()</samp> for
the <em>hstmt</em>.</td>
</tr>
<tr><td align="left" valign="top" width="25%" headers="d0e253 "><strong>HY</strong>013 <strong>*</strong></td>
<td align="left" valign="top" width="25%" headers="d0e255 ">Memory management problem</td>
<td align="left" valign="top" width="50%" headers="d0e257 ">The driver is unable to access memory required
to support the processing or completion of the function.</td>
</tr>
<tr><td align="left" valign="top" width="25%" headers="d0e253 "><strong>HY</strong>C00</td>
<td align="left" valign="top" width="25%" headers="d0e255 ">Driver not capable</td>
<td align="left" valign="top" width="50%" headers="d0e257 ">The SQL data type of column <em>icol</em> is
not recognized by DB2 UDB CLI.</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="section"><h4 class="sectiontitle">Example</h4></div>
<div class="example" id="rzadpfndecol__xmdecol"><a name="rzadpfndecol__xmdecol"><!-- --></a> </div>
<div class="section"><h4 class="sectiontitle">References</h4><ul><li><a href="rzadpfncolat.htm#rzadpfncolat">SQLColAttributes - Obtain column attributes</a></li>
<li><a href="rzadpfnexecd.htm#rzadpfnexecd">SQLExecDirect - Execute a statement directly</a></li>
<li><a href="rzadpfnnrcol.htm#rzadpfnnrcol">SQLNumResultCols - Get number of result columns</a></li>
<li><a href="rzadpfnprep.htm#rzadpfnprep">SQLPrepare - Prepare a statement</a></li>
</ul>
</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 class="relref"><strong>Related reference</strong><br />
<div><a href="rzadpfncolat.htm">SQLColAttributes - Obtain column attributes</a></div>
</div>
</div>
</body>
</html>