162 lines
10 KiB
HTML
162 lines
10 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="SQLError - Retrieve error information" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzadphdapi.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzadphddiag.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="rzadpfnerror" />
|
|
<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>SQLError</title>
|
|
</head>
|
|
<body id="rzadpfnerror"><a name="rzadpfnerror"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">SQLError - Retrieve error information</h1>
|
|
<div><div class="section"></div>
|
|
<div class="section"><h4 class="sectiontitle">Purpose</h4> <p><samp class="codeph">SQLError()</samp> returns
|
|
the diagnostic information associated with the most recently called DB2<sup>®</sup> UDB CLI function
|
|
for a particular statement, connection or environment handle.</p>
|
|
<p>The
|
|
information consists of a standardized SQLSTATE, an error code, and a text
|
|
message. Refer to <a href="rzadphddiag.htm#rzadphddiag">Diagnostics in a DB2 UDB CLI application</a> for more
|
|
information.</p>
|
|
<p>Call <samp class="codeph">SQLError()</samp> after receiving a return
|
|
code of SQL_ERROR or SQL_SUCCESS_WITH_INFO from another function call.</p>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Syntax</h4><pre>SQLRETURN SQLError (SQLHENV henv,
|
|
SQLHDBC hdbc,
|
|
SQLHSTMT hstmt,
|
|
SQLCHAR *szSqlState,
|
|
SQLINTEGER *pfNativeError,
|
|
SQLCHAR *szErrorMsg,
|
|
SQLSMALLINT cbErrorMsgMax,
|
|
SQLSMALLINT *pcbErrorMsg);</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. SQLError arguments</caption><thead align="left"><tr><th align="left" valign="bottom" width="22.22222222222222%" id="d0e64">Data type</th>
|
|
<th align="left" valign="bottom" width="20.74074074074074%" id="d0e66">Argument</th>
|
|
<th align="left" valign="bottom" width="16.85185185185185%" id="d0e68">Use</th>
|
|
<th align="left" valign="bottom" width="40.18518518518518%" id="d0e70">Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td align="left" valign="top" width="22.22222222222222%" headers="d0e64 ">SQLCHAR *</td>
|
|
<td align="left" valign="top" width="20.74074074074074%" headers="d0e66 "><em>szErrorMsg</em></td>
|
|
<td align="left" valign="top" width="16.85185185185185%" headers="d0e68 ">Output</td>
|
|
<td align="left" valign="top" width="40.18518518518518%" headers="d0e70 ">Pointer to buffer to contain the implementation
|
|
defined message text. In DB2 UDB CLI, only the DBMS generated messages is returned; DB2 UDB
|
|
CLI itself does not return any message text describing the problem.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="22.22222222222222%" headers="d0e64 ">SQLCHAR *</td>
|
|
<td align="left" valign="top" width="20.74074074074074%" headers="d0e66 "><em>szSqlState</em></td>
|
|
<td align="left" valign="top" width="16.85185185185185%" headers="d0e68 ">Output</td>
|
|
<td align="left" valign="top" width="40.18518518518518%" headers="d0e70 ">SQLSTATE as a string of 5 characters terminated
|
|
by a null character. The first 2 characters indicate error class; the next
|
|
3 indicate subclass. The values correspond directly to SQLSTATE values defined
|
|
in the X/Open SQL CAE specification and the ODBC specification, augmented
|
|
with IBM<sup>®</sup> specific
|
|
and product specific SQLSTATE values.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="22.22222222222222%" headers="d0e64 ">SQLHDBC</td>
|
|
<td align="left" valign="top" width="20.74074074074074%" headers="d0e66 "><em>hdbc</em></td>
|
|
<td align="left" valign="top" width="16.85185185185185%" headers="d0e68 ">Input</td>
|
|
<td align="left" valign="top" width="40.18518518518518%" headers="d0e70 ">Database connection handle. To obtain diagnostic
|
|
information associated with a connection, pass a valid database connection
|
|
handle, and set <em>hstmt</em> to SQL_NULL_HSTMT. The <em>henv</em> argument is
|
|
ignored.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="22.22222222222222%" headers="d0e64 ">SQLHENV</td>
|
|
<td align="left" valign="top" width="20.74074074074074%" headers="d0e66 "><em>henv</em></td>
|
|
<td align="left" valign="top" width="16.85185185185185%" headers="d0e68 ">Input</td>
|
|
<td align="left" valign="top" width="40.18518518518518%" headers="d0e70 ">Environment handle. To obtain diagnostic
|
|
information associated with an environment, pass a valid environment handle.
|
|
Set <em>hdbc</em> to SQL_NULL_HDBC. Set <em>hstmt</em> to SQL_NULL_HSTMT.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="22.22222222222222%" headers="d0e64 ">SQLHSTMT</td>
|
|
<td align="left" valign="top" width="20.74074074074074%" headers="d0e66 "><em>hstmt</em></td>
|
|
<td align="left" valign="top" width="16.85185185185185%" headers="d0e68 ">Input</td>
|
|
<td align="left" valign="top" width="40.18518518518518%" headers="d0e70 ">Statement handle. To obtain diagnostic information
|
|
associated with a statement, pass a valid statement handle. The <em>henv</em> and <em>hdbc</em> arguments
|
|
are ignored.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="22.22222222222222%" headers="d0e64 ">SQLINTEGER *</td>
|
|
<td align="left" valign="top" width="20.74074074074074%" headers="d0e66 "><em>pfNativeError</em></td>
|
|
<td align="left" valign="top" width="16.85185185185185%" headers="d0e68 ">Output</td>
|
|
<td align="left" valign="top" width="40.18518518518518%" headers="d0e70 ">Native error code. In DB2 UDB CLI, the <em>pfNativeError</em> argument
|
|
contains the SQLCODE value returned by the Database Management System (DBMS).
|
|
If the error is generated by DB2 UDB CLI and not the DBMS, this field is set to -99999.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="22.22222222222222%" headers="d0e64 ">SQLSMALLINT *</td>
|
|
<td align="left" valign="top" width="20.74074074074074%" headers="d0e66 "><em>pcbErrorMsg</em></td>
|
|
<td align="left" valign="top" width="16.85185185185185%" headers="d0e68 ">Output</td>
|
|
<td align="left" valign="top" width="40.18518518518518%" headers="d0e70 ">Pointer to total number of bytes available
|
|
to return to the <em>szErrorMsg</em> buffer.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="22.22222222222222%" headers="d0e64 ">SQLSMALLINT</td>
|
|
<td align="left" valign="top" width="20.74074074074074%" headers="d0e66 "><em>cbErrorMsgMax</em></td>
|
|
<td align="left" valign="top" width="16.85185185185185%" headers="d0e68 ">Input</td>
|
|
<td align="left" valign="top" width="40.18518518518518%" headers="d0e70 ">Maximum (that is, the allocated) length of
|
|
the buffer <em>szErrorMsg</em>. The recommended length to allocate is SQL_MAX_MESSAGE_LENGTH
|
|
+ 1.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Usage</h4><p>The SQLSTATEs are those defined by the X/OPEN
|
|
SQL CAE and the X/Open SQL CLI snapshot, augmented with IBM specific and
|
|
product specific SQLSTATE values.</p>
|
|
<div class="p">: <ul><li>To obtain diagnostic information associated with an environment,
|
|
pass a valid environment handle. Set <em>hdbc</em> to SQL_NULL_HDBC.
|
|
Set <em>hstmt</em> to SQL_NULL_HSTMT.</li>
|
|
<li>To obtain diagnostic information associated with a connection, pass a
|
|
valid database connection handle, and set <em>hstmt</em> to SQL_NULL_HSTMT.
|
|
The <em>henv</em> argument is ignored.</li>
|
|
<li>To obtain diagnostic information associated with a statement, pass a valid
|
|
statement handle. The <em>henv</em> and <em>hdbc</em> arguments are ignored.</li>
|
|
</ul>
|
|
</div>
|
|
<p>If diagnostic information generated by one DB2 UDB CLI function is not retrieved before
|
|
a function other than <samp class="codeph">SQLError()</samp> is called with the same
|
|
handle, the information for the previous function call is lost. This is true
|
|
whether diagnostic information is generated for the second DB2 UDB CLI function
|
|
call.</p>
|
|
<p>To avoid truncation of the error message, declare a buffer length
|
|
of SQL_MAX_MESSAGE_LENGTH + 1. The message text is never longer than this.</p>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Return codes</h4><ul><li>SQL_ERROR</li>
|
|
<li>SQL_INVALID_HANDLE</li>
|
|
<li>SQL_NO_DATA_FOUND</li>
|
|
<li>SQL_SUCCESS</li>
|
|
</ul>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Diagnostics</h4><p>SQLSTATEs are not defined because <samp class="codeph">SQLError()</samp> does
|
|
not generate diagnostic information for itself. SQL_ERROR is returned if argument <samp class="codeph">szSqlState</samp>, <samp class="codeph">pfNativeError</samp>, <samp class="codeph">szErrorMsg</samp>, or <samp class="codeph">pcbErrorMsg</samp> is a null pointer.</p>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Example</h4></div>
|
|
<div class="example"> </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="relconcepts"><strong>Related concepts</strong><br />
|
|
<div><a href="rzadphddiag.htm" title="This topic deals with warning or error conditions generated within an application.">Diagnostics in a DB2 UDB CLI application</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |