87 lines
5.9 KiB
HTML
87 lines
5.9 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="Handle SQL error return codes using the SQLCA" />
|
|
<meta name="abstract" content="When an SQL statement is processed in your program, SQL places a return code in the SQLCODE and SQLSTATE fields. The return codes indicate the success or failure of the running of your statement." />
|
|
<meta name="description" content="When an SQL statement is processed in your program, SQL places a return code in the SQLCODE and SQLSTATE fields. The return codes indicate the success or failure of the running of your statement." />
|
|
<meta name="DC.subject" content="concept, host language, using SQL with, handling return code, SQLCODEs, SQLSTATEs, handling, error return code, SQLCODEs and SQLSTATEs, error return code, handling, general, return code, handling in, definition, problem handling, warning, test for negative SQLCODEs, WHENEVER SQLERROR, statements, SQLERROR statement, WHENEVER, WHENEVER SQLERROR" />
|
|
<meta name="keywords" content="concept, host language, using SQL with, handling return code, SQLCODEs, SQLSTATEs, handling, error return code, SQLCODEs and SQLSTATEs, error return code, handling, general, return code, handling in, definition, problem handling, warning, test for negative SQLCODEs, WHENEVER SQLERROR, statements, SQLERROR statement, WHENEVER, WHENEVER SQLERROR" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpsqlcom.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../db2/rbafzmst02.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../rzala/rzalakickoff.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="rzajperrtncd" />
|
|
<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>Handle SQL error return codes using the SQLCA</title>
|
|
</head>
|
|
<body id="rzajperrtncd"><a name="rzajperrtncd"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Handle SQL error return codes using the SQLCA</h1>
|
|
<div><p>When an SQL statement is processed in your program, SQL places
|
|
a return code in the SQLCODE and SQLSTATE fields. The return codes indicate
|
|
the success or failure of the running of your statement.</p>
|
|
<div class="section"><div class="p">If SQL encounters an error while processing the statement, the
|
|
SQLCODE is a negative number and SUBSTR(SQLSTATE,1,2) is not '00', '01', or
|
|
'02'. If SQL encounters an exception but valid condition while processing
|
|
your statement, the SQLCODE is a positive number and SUBSTR(SQLSTATE,1,2)
|
|
is '01' or '02'. If your SQL statement is processed without encountering an
|
|
error or warning condition, the SQLCODE is zero and the SQLSTATE is '00000'.
|
|
<div class="note"><span class="notetitle">Note:</span> There are situations when a zero SQLCODE is returned to your program
|
|
and the result might not be satisfactory. For example, if a value was truncated
|
|
as a result of running your program, the SQLCODE returned to your program
|
|
is zero. However, one of the SQL warning flags (SQLWARN1) indicates truncation.
|
|
In this case, the SQLSTATE is not '00000'.</div>
|
|
</div>
|
|
</div>
|
|
<div class="section"> <div class="attention"><span class="attentiontitle">Attention:</span> If you do not test for negative SQLCODEs
|
|
or specify a WHENEVER SQLERROR statement, your program will continue to the
|
|
next statement. Continuing to run after an error can produce unpredictable
|
|
results.</div>
|
|
</div>
|
|
<div class="section"><p>The main purpose for SQLSTATE is to provide common return codes
|
|
for common return conditions among the different IBM<sup>®</sup> relational database systems. SQLSTATEs
|
|
are particularly useful when handling problems with distributed database operations.</p>
|
|
</div>
|
|
<div class="section"><p>Because the SQLCA 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 the SQLCA. Especially important
|
|
are the following SQLCA fields: </p>
|
|
<dl><dt class="dlterm">SQLCODE</dt>
|
|
<dd>Return code.</dd>
|
|
<dt class="dlterm">SQLSTATE</dt>
|
|
<dd>Return code.</dd>
|
|
<dt class="dlterm">SQLERRD(3)</dt>
|
|
<dd>The number of rows updated, inserted, or deleted by SQL.</dd>
|
|
<dt class="dlterm">SQLWARN0</dt>
|
|
<dd>If set to W, at least one of the SQL warning flags (SQLWARN1 through SQLWARNA)
|
|
is set.</dd>
|
|
</dl>
|
|
</div>
|
|
<div class="section"></div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzajpsqlcom.htm" title="This topic describes some concepts and rules that are common to using SQL statements in a host language.">Common concepts and rules for using embedded SQL</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>
|
|
</div>
|
|
</body>
|
|
</html> |