121 lines
6.8 KiB
HTML
121 lines
6.8 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="Data retrieval errors" />
|
|
<meta name="abstract" content="Sometimes when you issue a statement, it encounters an error." />
|
|
<meta name="description" content="Sometimes when you issue a statement, it encounters an error." />
|
|
<meta name="DC.subject" content="SELECT statement, data retrieval errors" />
|
|
<meta name="keywords" content="SELECT statement, data retrieval errors" />
|
|
<meta name="DC.Relation" scheme="URI" content="rbafytexas.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="rbafyretrievalerrors" />
|
|
<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>Data retrieval errors</title>
|
|
</head>
|
|
<body id="rbafyretrievalerrors"><a name="rbafyretrievalerrors"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Data retrieval errors</h1>
|
|
<div><p>Sometimes when you issue a statement, it encounters an error.</p>
|
|
<div class="section"><p>If SQL finds that a retrieved character or graphic column is too
|
|
long to be placed in a host variable, SQL does the following:</p>
|
|
<ul><li>Truncates the data while assigning the value to the host variable.</li>
|
|
<li>Sets SQLWARN0 and SQLWARN1 in the SQLCA to the value 'W'or sets RETURNED_SQLSTATE
|
|
to '01004' in the SQL diagnostics area.</li>
|
|
<li>Sets the indicator variable, if provided, to the length of the value before
|
|
truncation.</li>
|
|
</ul>
|
|
</div>
|
|
<div class="section"><p>If SQL finds a data mapping error while running a statement, one
|
|
of two things occurs:</p>
|
|
<ul><li>If the error occurs on an expression in the SELECT list and an indicator
|
|
variable is provided for the expression in error: <ul><li>SQL returns a -2 for the indicator variable corresponding to the expression
|
|
in error.</li>
|
|
<li>SQL returns all valid data for that row.</li>
|
|
<li>SQL returns a positive SQLCODE.</li>
|
|
</ul>
|
|
</li>
|
|
<li>If an indicator variable is not provided, SQL returns the corresponding
|
|
negative SQLCODE.</li>
|
|
</ul>
|
|
</div>
|
|
<div class="section"><p>Data mapping errors include:</p>
|
|
<ul><li>+138 - Argument of the substringing function is not valid.</li>
|
|
<li>+180 - Syntax for a string representation of a date, time, or timestamp
|
|
is not valid.</li>
|
|
<li>+181 - String representation of a date, time, or timestamp is not a valid
|
|
value.</li>
|
|
<li>+183 - Invalid result from a date/time expression. The resulting date
|
|
or timestamp is not within the valid range of dates or timestamps.</li>
|
|
<li>+191 - MIXED data is not properly formed.</li>
|
|
<li>+304 - Numeric conversion error (for example, overflow, underflow, or
|
|
division by zero).</li>
|
|
<li>+331 - Characters cannot be converted.</li>
|
|
<li>+420 - Character in the CAST argument is not valid.</li>
|
|
<li>+802 - Data conversion or data mapping error.</li>
|
|
</ul>
|
|
</div>
|
|
<div class="section"><p>For data mapping errors, the SQLCA reports only the last error
|
|
detected. The indicator variable corresponding to each result column having
|
|
an error is set to -2.</p>
|
|
</div>
|
|
<div class="section"><p>For data mapping errors on a multi-row FETCH, each mapping error
|
|
reported as a warning SQLSTATE will have a separate condition area in the
|
|
SQL diagnostics area. Note that SQL stops on the first error, so only one
|
|
mapping error that is reported as an error SQLSTATE will be returned in the
|
|
SQL diagnostics area. </p>
|
|
</div>
|
|
<div class="section"><p>For all other SQL statements, only the last warning SQLSTATE will
|
|
be reported in the SQL diagnostics area.</p>
|
|
</div>
|
|
<div class="section"><p>If the full-select contains DISTINCT in the select list and a
|
|
column in the select list contains numeric data that is not valid, the data
|
|
is considered equal to a null value if the query is completed as a sort. If
|
|
an existing index is used, the data is not considered equal to a null.</p>
|
|
</div>
|
|
<div class="section"><p>The impact of data mapping errors on the ORDER BY clause depends
|
|
on the situation: </p>
|
|
<ul><li>If the data mapping error occurs while data is being assigned to a host
|
|
variable in a SELECT INTO or FETCH statement, and that same expression is
|
|
used in the ORDER BY clause, the result record is ordered based on the value
|
|
of the expression. It is not ordered as if it were a null (higher than all
|
|
other values). This is because the expression was evaluated before the assignment
|
|
to the host variable is attempted.</li>
|
|
<li>If the data mapping error occurs while an expression in the select-list
|
|
is being evaluated and the same expression is used in the ORDER BY clause,
|
|
the result column is normally ordered as if it were a null value (higher than
|
|
all other values). If the ORDER BY clause is implemented by using a sort,
|
|
the result column is ordered as if it were a null value. If the ORDER BY clause
|
|
is implemented by using an existing index, in the following cases, the result
|
|
column is ordered based on the actual value of the expression in the index: <ul><li>The expression is a date column with a date format of *MDY, *DMY, *YMD,
|
|
or *JUL, and a date conversion error occurs because the date is not within
|
|
the valid range for dates.</li>
|
|
<li>The expression is a character column and a character cannot be converted.</li>
|
|
<li>The expression is a decimal column and a numeric value that is not valid
|
|
is detected.</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafytexas.htm" title="Learn a variety of ways of tailoring your query to gather data using the SELECT statement. One way to do this is to use the SELECT statement in a program to retrieve a specific row (for example, the row for an employee). Furthermore, you can use clauses to gather data in a specific way.">Retrieve data using the SELECT statement</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |