77 lines
4.3 KiB
HTML
77 lines
4.3 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="concept" />
|
||
|
<meta name="DC.Title" content="DB2 UDB CLI SQLSTATEs" />
|
||
|
<meta name="DC.subject" content="SQLSTATEs" />
|
||
|
<meta name="keywords" content="SQLSTATEs" />
|
||
|
<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="rzadpsqlstates" />
|
||
|
<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>DB2 UDB
|
||
|
CLI SQLSTATEs</title>
|
||
|
</head>
|
||
|
<body id="rzadpsqlstates"><a name="rzadpsqlstates"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">DB2 UDB
|
||
|
CLI SQLSTATEs</h1>
|
||
|
<div><p>Because different database servers often have different diagnostic message
|
||
|
codes, DB2<sup>®</sup> UDB
|
||
|
CLI provides a standard set of <em>SQLSTATEs</em> that are defined by the X/Open
|
||
|
SQL CAE specification. This allows consistent message handling across different
|
||
|
database servers.</p>
|
||
|
<div class="p">SQLSTATEs are alphanumeric strings
|
||
|
of 5 characters (bytes) with a format of <samp class="codeph">ccsss</samp>, where <samp class="codeph">cc</samp> indicates
|
||
|
class and <samp class="codeph">sss</samp> indicates subclass. Any SQLSTATE that has a
|
||
|
class of: <ul><li>01, is a warning.</li>
|
||
|
<li>HY, is generated by the CLI driver (either DB2 UDB CLI or ODBC).</li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<p>The <samp class="codeph">SQLError()</samp> function also returns an
|
||
|
error code if the code is generated by the server. When connected to an IBM<sup>®</sup> database
|
||
|
server, the error code is SQLCODE. If the code is generated by DB2 UDB CLI instead
|
||
|
of at the server, then the error code is set to -99999.</p>
|
||
|
<p>DB2 UDB
|
||
|
CLI SQLSTATEs include both additional IBM defined SQLSTATEs that are returned
|
||
|
by the database server, and DB2 UDB CLI defined SQLSTATEs for conditions that are
|
||
|
not defined in the X/Open specification. This allows for the maximum amount
|
||
|
of diagnostic information to be returned. When running applications in Windows<sup>®</sup> using
|
||
|
ODBC, it is also possible to receive ODBC defined SQLSTATEs.</p>
|
||
|
<div class="p">Follow these
|
||
|
guidelines for using SQLSTATEs within your application: <ul><li>Always check the function return code before calling <samp class="codeph">SQLError()</samp> to
|
||
|
determine if diagnostic information is available.</li>
|
||
|
<li>Use the SQLSTATEs rather than the error code.</li>
|
||
|
<li>To increase your application's portability, only build dependencies on
|
||
|
the subset of DB2 UDB
|
||
|
CLI SQLSTATEs that are defined by the X/Open specification, and return the
|
||
|
additional ones as information only. (Dependencies refers to the application
|
||
|
making logic flow decisions based on specific SQLSTATEs.)</li>
|
||
|
<li>For maximum diagnostic information, return the text message along with
|
||
|
the SQLSTATE (if applicable, the text message includes the IBM defined
|
||
|
SQLSTATE). It is also useful for the application to print out the name of
|
||
|
the function that returned the error.</li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div>
|
||
|
<div class="familylinks">
|
||
|
<div class="parentlink"><strong>Parent topic:</strong> <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>
|