127 lines
8.3 KiB
HTML
127 lines
8.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="SQLCODE and SQLSTATE concepts" />
|
||
|
<meta name="abstract" content="This reference provides a list of SQLCODEs and their associated SQLSTATEs. In this reference, you can find instructions for finding a SQLCODE in the message file along with the text for these messages." />
|
||
|
<meta name="description" content="This reference provides a list of SQLCODEs and their associated SQLSTATEs. In this reference, you can find instructions for finding a SQLCODE in the message file along with the text for these messages." />
|
||
|
<meta name="DC.Relation" scheme="URI" content="rzalakickoff.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="rzalaclass.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="rzalaccl.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="rzalafinder.htm" />
|
||
|
<meta name="copyright" content="(C) Copyright IBM Corporation 2001, 2006" />
|
||
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2001, 2006" />
|
||
|
<meta name="DC.Format" content="XHTML" />
|
||
|
<meta name="DC.Identifier" content="codestate.dita" />
|
||
|
<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>SQLCODE and SQLSTATE concepts</title>
|
||
|
</head>
|
||
|
<body id="codestate.dita"><a name="codestate.dita"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">SQLCODE and SQLSTATE concepts</h1>
|
||
|
<div><p>This reference provides a list of SQLCODEs and their associated
|
||
|
SQLSTATEs. In this reference, you can find instructions for finding a SQLCODE
|
||
|
in the message file along with the text for these messages.</p>
|
||
|
<p>SQLCODEs and SQLSTATEs are returned in the SQLCA structure or
|
||
|
through the GET DIAGNOSTICS statement. SQLSTATE is the preferred standard
|
||
|
return code. It provides application programs with return codes for common
|
||
|
error conditions found among the DB2 Universal Database™ products.
|
||
|
SQLSTATEs are particularly useful when handling errors in distributed SQL
|
||
|
applications.</p>
|
||
|
<div class="section" id="codestate.dita__codeconcept"><a name="codestate.dita__codeconcept"><!-- --></a><h4 class="sectiontitle">SQLCODE</h4><p>An SQLCODE is a return
|
||
|
code. The return code is sent by the database manager after completion of
|
||
|
each SQL statement.</p>
|
||
|
<p>Each SQLCODE that is recognized by a DB2<sup>®</sup> UDB for iSeries™ server
|
||
|
has a corresponding message in the message file QSQLMSG. The message identifier
|
||
|
for any SQLCODE is constructed by appending the absolute value (5 digits)
|
||
|
of the SQLCODE to SQ and changing the third character to L if the first character
|
||
|
of the SQLCODE is 0. For example, if the SQLCODE is 30070, the message identifier
|
||
|
is SQ30070. If the SQLCODE is -0204, the message identifier is SQL0204. Lastly,
|
||
|
if the SQLCODE is a 3-digit positive number, a zero is added before the first
|
||
|
digit. For example, if the SQLCODE is 551, the message identifier is SQL0551.</p>
|
||
|
</div>
|
||
|
<div class="section" id="codestate.dita__sqlstateconcept"><a name="codestate.dita__sqlstateconcept"><!-- --></a><h4 class="sectiontitle">SQLSTATE</h4><p>SQLSTATE provides
|
||
|
application programs with common return codes for success, warning, and error
|
||
|
conditions found among the DB2 Universal Database products. SQLSTATE
|
||
|
values are particularly useful when handling errors in distributed SQL applications.
|
||
|
SQLSTATE values are consistent with the SQLSTATE specifications contained
|
||
|
in the SQL 1999 standard. </p>
|
||
|
<div class="p">An SQLSTATE value is a return code that indicates
|
||
|
the outcome of the most recently executed SQL statement. The mechanism used
|
||
|
to access SQLSTATE values depends on where the SQL statement is executed.
|
||
|
In Java™,
|
||
|
SQLSTATE values are returned by using getSQLState() method. In SQL functions,
|
||
|
SQL procedures, SQL triggers, and embedded applications other than Java, SQLSTATE
|
||
|
values are returned in the following:<ul><li>The last five bytes of the SQLCA</li>
|
||
|
<li>A stand-alone SQLSTATE variable</li>
|
||
|
<li>The GET DIAGNOSTICS statement</li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<p>SQLSTATE values are designed so that application programs can
|
||
|
test for specific conditions or classes of conditions.</p>
|
||
|
<p>SQLSTATE values
|
||
|
are comprised of a two-character class code value, followed by a three-character
|
||
|
subclass code value. Class code values represent classes of successful and
|
||
|
unsuccessful completion conditions. If you want to use SQLSTATE as the basis
|
||
|
of your application's return codes, you can define your own SQLSTATE classes
|
||
|
or subclasses using the following guidelines:</p>
|
||
|
<div class="p"><ul><li>SQLSTATE classes that begin with the characters 7 through 9 or I through
|
||
|
Z can be defined. Within these classes, any subclass can be defined.</li>
|
||
|
<li>SQLSTATE classes that begin with the characters 0 through 6 or A through
|
||
|
H are reserved for the database manager. Within these classes, subclasses
|
||
|
that begin with the characters 0 through H are reserved for the database manager.
|
||
|
Subclasses that begin with the characters I through Z can be defined.</li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<p>The class code of an SQLSTATE value indicates whether the SQL
|
||
|
statement was executed successfully (class codes 00 and 01) or unsuccessfully
|
||
|
(all other class codes).</p>
|
||
|
<p>SQLSTATE is related to SQLCODE. Every SQLSTATE
|
||
|
has one or more SQLCODEs associated with it. An SQLSTATE can refer to more
|
||
|
than one SQLCODE.</p>
|
||
|
</div>
|
||
|
<div class="section" id="codestate.dita__returnedsqlstate"><a name="codestate.dita__returnedsqlstate"><!-- --></a><h4 class="sectiontitle">SQLSTATEs returned by non-DB2 UDB for iSeries application
|
||
|
servers</h4><p>When an SQLSTATE other than 00000 is returned
|
||
|
from an application server that is not DB2 UDB for iSeries, DB2 UDB for iSeries attempts to map the SQLSTATE
|
||
|
to a DB2 UDB
|
||
|
for iSeries SQLCODE
|
||
|
and message with the following results:</p>
|
||
|
<div class="p"><ul><li>If the SQLSTATE is not recognized by DB2 UDB for iSeries, the common message for the class
|
||
|
is issued.</li>
|
||
|
<li>If the SQLSTATE and SQLCODE correspond to a single DB2 UDB for iSeries SQLCODE, DB2 UDB attempts to convert the returned
|
||
|
tokens into the replacement data that the SQL message expects. If an error
|
||
|
occurs while converting the tokens:<ul><li>The tokens are returned without conversion in the SQLERRM field of the
|
||
|
SQLCA or in the SQL diagnostics area.</li>
|
||
|
<li>A common message for the class code of the SQLSTATE is issued.</li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div>
|
||
|
<div class="familylinks">
|
||
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzalakickoff.htm" title="Use this topic to find descriptions of codes and messages returned when using SQL with DB2 Universal Database for iSeries (DB2 UDB for iSeries). This topic contains listings of SQLCODEs, SQLSTATEs, class codes, and SQL messages.">SQL messages and codes</a></div>
|
||
|
</div>
|
||
|
<div class="relref"><strong>Related reference</strong><br />
|
||
|
<div><a href="rzalaclass.htm" title="The table below provides a list of general SQLSTATE classes. Each class links to a list of the more specific SQLSTATE codes that comprise that class.">Listing of SQLSTATE class codes</a></div>
|
||
|
<div><a href="rzalaccl.htm" title="The tables in this topic provide descriptions of SQLSTATE codes that can be returned to applications by DB2 UDB for iSeries. The tables include SQLSTATE values, their meanings, and their corresponding SQLCODE values.">Listing of SQLSTATE values</a></div>
|
||
|
</div>
|
||
|
<div class="relinfo"><strong>Related information</strong><br />
|
||
|
<div><a href="rzalafinder.htm">SQL message finder</a></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|