DB2 SQL Errors Codes and Error Messages and Warnings from Error -338 to -341

SQLServerF1

Error: DB2 SQL Error: SQLCODE=-342, SQLSTATE=42925, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
THE COMMON TABLE EXPRESSION
name MUST NOT USE SELECT
DISTINCT AND MUST USE UNION
ALL BECAUSE IT IS RECURSIVE
Explanation: There are two possible explanations:
v A fullselect within the common table expression
name cannot start with SELECT DISTINCT because
the common table expression is recursive.
v A fullselect within the common table expression
name specified UNION instead of UNION ALL as
required for recursive common table expressions.
System action: The statement cannot be executed.
Programmer response: Remove the keyword
DISTINCT from the common table expression, add the
keyword ALL following UNION, or remove the
recursive reference within the common table
expression.
SQLSTATE: 42925

Error: DB2 SQL Error: SQLCODE=-343, SQLSTATE=42908, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
THE COLUMN NAMES ARE
REQUIRED FOR THE RECURSIVE
COMMON TABLE EXPRESSION name
Explanation: The recursive common table expression
name name must include the specification of the
column names following the identifier of the common
table expression.
System action: The statement cannot be executed.
Programmer response: Add column names following
the identifier of the common table expressions.
SQLSTATE: 42908

Error: DB2 SQL Error: SQLCODE=-344, SQLSTATE=42825, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
THE RECURSIVE COMMON TABLE
EXPRESSION name HAS
MISMATCHED DATA TYPES OR
LENGTHS OR CODE PAGE FOR
COLUMN column-name
Explanation: The recursive common table expression
name name has a column column-name that is referred to
in the iterative fullselect of the common table
expression. The data type and length are set based on
the initialization fullselect for this column. The result of
the expression for the column column-name in the
iterative fullselect has a different data type or length
that may result in failure to assign the value for the
column.
System action: The statement cannot be executed.
Programmer response: Correct the column used in the
fullselects of the recursive common table expression so
that the initialization column matches the iterative
columns.
SQLSTATE: 42825

Above are list of DB2 SQL Errors and Warnings from Error -338 to -341 received while performing certain operation against DB2 Database or related products.

SQLCODE – Regardless of whether the application program provides an SQLCA or a stand-alone variable, SQLCODE is set by DB2 after each SQL statement is
executed. DB2 conforms to the ISO/ANSI SQL standard as follows:
If SQLCODE = 0, execution was successful.
If SQLCODE > 0, execution was successful with a warning.
If SQLCODE < 0, execution was not successful.
SQLCODE = 100, “no data” was found. For example, a FETCH statement returned no data because the cursor was positioned after the last row of the result table.

SQLSTATE – SQLSTATE is also set by DB2 after the execution of each SQL statement. Thus, application programs can check the execution of SQL statements by testing SQLSTATE instead of SQLCODE.

Hope this was helpful.

Thanks,
SQLServerF1 Team
Information about DB2 SQL Error Codes and Error Messages on Windows, Linux and Z/OS Operating Systems.

 

Leave a Reply

Your email address will not be published. Required fields are marked *