Database SQL Messages and Codes
Total Page:16
File Type:pdf, Size:1020Kb
IBM i 7.3 Database SQL messages and codes IBM Note Before using this information and the product it supports, read the information in “Notices” on page 291. This edition applies to IBM i 7.3 (product number 5770-SS1) and to all subsequent releases and modifications until otherwise indicated in new editions. This version does not run on all reduced instruction set computer (RISC) models nor does it run on CISC models. This document may contain references to Licensed Internal Code. Licensed Internal Code is Machine Code and is licensed to you under the terms of the IBM License Agreement for Machine Code. © Copyright International Business Machines Corporation 2001, 2015. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents SQL messages and codes....................................................................................... 1 What's new for IBM i 7.3..............................................................................................................................1 PDF file for SQL messages and codes......................................................................................................... 1 SQLCODE and SQLSTATE concepts............................................................................................................. 1 Listing of SQLSTATE class codes................................................................................................................. 3 Listing of SQLSTATE values..........................................................................................................................5 SQL message concepts..............................................................................................................................33 Listing of SQL messages............................................................................................................................ 33 Notices..............................................................................................................291 Trademarks.............................................................................................................................................. 292 Terms and conditions.............................................................................................................................. 292 iii iv SQL messages and codes Use this topic collection to find descriptions of codes and messages returned when using SQL with Db2® for i. This topic contains listings of SQLCODEs, SQLSTATEs, class codes, and SQL messages. Note: By using the code examples, you agree to the terms of the “Code license and disclaimer information” on page 290. What's new for IBM i 7.3 Read about new or significantly changed information for the SQL messages and codes topic collection. New messages and codes added Several additions were made to the “Listing of SQLSTATE values” on page 5 and the Listing of SQL messages. How to see what's new or changed To help you see where technical changes have been made, this information uses: • The image to mark where new or changed information begins. • The image to mark where new or changed information ends. In PDF files, you might see revision bars (|) in the left margin of new and changed information. To find other information about what's new or changed this release, see the Memo to users. PDF file for SQL messages and codes You can view and print a PDF file of this information. To view or download the PDF version of this document, select SQL messages and codes. Saving PDF files To save a PDF on your workstation for viewing or printing: 1. Right-click the PDF link in your browser. 2. Click the option that saves the PDF locally. 3. Navigate to the directory in which you want to save the PDF. 4. Click Save. Downloading Adobe Reader You need Adobe Reader installed on your system to view or print these PDFs. You can download a free copy from the Adobe Web site (http://get.adobe.com/reader/) . SQLCODE and SQLSTATE concepts 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. 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® products. SQLSTATEs are particularly useful when handling errors in distributed SQL applications. © Copyright IBM Corp. 2001, 2015 1 SQLCODE An SQLCODE is a return code. The return code is sent by the database manager after completion of each SQL statement. Each SQLCODE that is recognized by a Db2 for i application 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. SQLSTATE SQLSTATE provides application programs with common return codes for success, warning, and error conditions that are found among the DB2 products. SQLSTATE values are particularly useful when handling errors in distributed SQL applications. SQLSTATE values are consistent with the SQLSTATE specifications that are contained in the SQL 1999 standard. 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 the getSQLState() method. In SQL functions, SQL procedures, SQL triggers, and embedded applications other than Java, SQLSTATE values are returned in the following ways: • The last five bytes of the SQLCA • A stand-alone SQLSTATE variable • The GET DIAGNOSTICS statement SQLSTATE values are designed so that application programs can test for specific conditions or classes of conditions. 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: • 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. • 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. 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). SQLSTATE is related to SQLCODE. Every SQLSTATE has one or more SQLCODEs associated with it. An SQLSTATE can refer to more than one SQLCODE. SQLSTATEs returned from application servers that are not Db2 for i When an SQLSTATE other than 00000 is returned from an application server that is not Db2 for i, Db2 for i attempts to map the SQLSTATE to a Db2 for i SQLCODE and message with the following results: • If the SQLSTATE is not recognized by Db2 for i, the common message for the class is issued. • If the SQLSTATE and SQLCODE correspond to a single Db2 for i SQLCODE, Db2 for i attempts to convert the returned tokens into the replacement data that the SQL message expects. If an error occurs while converting the tokens, the following results occur: 2 IBM i: SQL messages and codes – The tokens are returned without conversion in the SQLERRM field of the SQLCA or in the SQL diagnostics area. – A common message for the class code of the SQLSTATE is issued. Related reference Listing of SQLSTATE class codes This table 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 values The tables in this topic provide descriptions of SQLSTATE codes that can be returned to applications by DB2 for i. The tables include SQLSTATE values, their meanings, and their corresponding SQLCODE values. SQL message finder Listing of SQLSTATE class codes This table provides a list of general SQLSTATE classes. Each class links to a list of the more specific SQLSTATE codes that comprise that class. Table 1. SQLSTATE Class Codes Class code Meaning Subcodes 00 Unqualified Successful Completion Table 2 on page 5 01 Warning Table 3 on page 5 02 No Data Table 4 on page 8 07 Dynamic SQL Error Table 5 on page 9 08 Connection Exception Table 6 on page 9 09 Triggered Action Exception Table 7 on page 9 0A Feature Not Supported Table 8 on page 9 0E Invalid Schema Name List Specification Table 9 on page 10 0F Invalid Token Table 10 on page 10 0K Resignal When Handler Not Active Table 11 on page 10 0N SQL/XML Mapping Error Table 12 on page 10 0W Prohibited Statement Encountered During Trigger Table 13 on page 10 0Z Diagnostics Exception Table 14 on page 10