ibm-information-center/dist/eclipse/plugins/i5OS.ic.ddp_5.4.0.1/rbal1sqlc.htm

103 lines
6.6 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="SQLCODEs and SQLSTATEs" />
<meta name="abstract" content="Program interfaces using SQL return error information to the application program when an error occurs. SQLSTATEs and their corresponding SQLCODEs are returned to the application program in either the SQL communication area (SQLCA) or the SQL diagnostic area." />
<meta name="description" content="Program interfaces using SQL return error information to the application program when an error occurs. SQLSTATEs and their corresponding SQLCODEs are returned to the application program in either the SQL communication area (SQLCA) or the SQL diagnostic area." />
<meta name="DC.subject" content="collection, SQL communication area (SQLCA), application program, SQLCODE, SQLSTATE, SQLCODE error code, error handling, for distributed relational database, SQLSTATE error code" />
<meta name="keywords" content="collection, SQL communication area (SQLCA), application program, SQLCODE, SQLSTATE, SQLCODE error code, error handling, for distributed relational database, SQLSTATE error code" />
<meta name="DC.Relation" scheme="URI" content="rbal1appprob.htm" />
<meta name="DC.Relation" scheme="URI" content="rbal1aspcoda.htm" />
<meta name="DC.Relation" scheme="URI" content="../db2/rbafzmst02.htm" />
<meta name="DC.Relation" scheme="URI" content="../rzala/rzalakickoff.htm" />
<meta name="DC.Relation" scheme="URI" content="../cl/dspmsgd.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rbal1sqlc" />
<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>SQLCODEs and SQLSTATEs</title>
</head>
<body id="rbal1sqlc"><a name="rbal1sqlc"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">SQLCODEs and SQLSTATEs</h1>
<div><p>Program interfaces using SQL return error information to the application
program when an error occurs. SQLSTATEs and their corresponding SQLCODEs are
returned to the application program in either the SQL communication area (SQLCA)
or the SQL diagnostic area.</p>
<div class="section"><p>An SQLCA is a collection of variables in a control block in space
provided by the application that is updated by the database management system
with information about the SQL statement most recently run. An SQL diagnostic
area is a more complex storage area in space provided by the database manager
that is designed to communicate more extensive information about the SQL statement
most recently run. </p>
</div>
<div class="section"><p>When an SQL error is detected, a five-character global variable
called the SQLSTATE identifies the nature of the error. In addition to the
SQLSTATE, an integer SQLCODE is also available. However, the SQLCODE does
not return the same return code for the same error condition among the current
four IBM<sup>®</sup> relational
database products. SQLSTATE has been designed so that application programs
can test for specific error conditions or classes of errors regardless of
which DB2<sup>®</sup> product
the application is connected to.</p>
</div>
<div class="section"><p>If SQL encounters a hard error while processing a statement, the
SQLCODE is a negative number (for example, SQLCODE -204). If SQL encounters
an exceptional but valid condition (warning) while processing a statement,
the SQLCODE is a positive number (for example, SQLCODE +100). If SQL encounters
no error or exceptional condition while processing a statement, the SQLCODE
is 0. Every <span class="keyword">DB2 Universal Database™ for iSeries™</span> SQLCODE
has a corresponding message in message file QSQLMSG in library QSYS. For example,
SQLCODE -204 is logged as message ID SQL0204.</p>
</div>
<div class="section"><p>Because the returned error information is a valuable problem-diagnosis
tool, it is a good idea to include in your application programs the instructions
necessary to display some of the information contained in either the returned
SQLCA or SQL diagnostic area. The message tokens discussed here are also very
valuable for problem diagnosis:</p>
</div>
<div class="section"><ul><li>SQLSTATE <p>Return code.</p>
</li>
<li>SQLCODE (SQLCA) or DB2_RETURNED_SQLCODE (SQL diagnostic area) <p>Return
code.</p>
</li>
<li>SQLERRD(3) (SQLCA) or ROW_COUNT (SQL diagnostic area) <p>The number of
rows updated, inserted, or deleted by SQL.</p>
</li>
</ul>
</div>
<div class="section"><p>The complete message can be viewed online by using the <span class="cmdname">Display
Message Description (DSPMSGD)</span> command.</p>
</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="rbal1aspcoda.htm">Distributed relational database SQLCODEs and SQLSTATEs</a></strong><br />
The list provides some of the common SQLCODEs and SQLSTATEs associated with distributed relational database processing.</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbal1appprob.htm" title="The best time to handle a problem with an application is before it goes into production. However, it is impossible to anticipate all the conditions that will exist for an application when it gets into general use.">Application problems</a></div>
</div>
<div class="relinfo"><strong>Related information</strong><br />
<div><a href="../db2/rbafzmst02.htm">SQL reference</a></div>
<div><a href="../rzala/rzalakickoff.htm">SQL messages and codes</a></div>
<div><a href="../cl/dspmsgd.htm">Display Message Description (DSPMSGD) command</a></div>
</div>
</div>
</body>
</html>