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

SQLServerF1

Error: DB2 SQL Error: SQLCODE=-338, SQLSTATE=42972, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
AN ON CLAUSE IS INVALID
SQLSTATE: 42972

Error: DB2 SQL Error: SQLCODE=-340, SQLSTATE=42726, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
THE COMMON TABLE EXPRESSION
name HAS THE SAME IDENTIFIER AS
ANOTHER OCCURRENCE OF A
COMMON TABLE EXPRESSION
DEFINITION WITHIN THE SAME
STATEMENT
Explanation: The common table expression name name
is used in the definition of more than one common
table expressions in the statement. The name used to
describe a common table expression must be unique
within the same statement.
System action: The statement cannot be executed.
Programmer response: Correct the error by changing
the name of one of the common table expressions.
SQLSTATE: 42726

Error: DB2 SQL Error: SQLCODE=-341, SQLSTATE=42835, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
A CYCLIC REFERENCE EXISTS
BETWEEN THE COMMON TABLE
EXPRESSIONS name1 AND name2
Explanation: The common table expression name1
refers to name2 in a FROM clause within its fullselect
and name2 refers to name1 in a FROM clause within its
fullselects. Such forms of cyclic references are not
allowed.
System action: The statement cannot be executed.
Programmer response: Remove the cyclic reference
from one of the common table expressions.
SQLSTATE: 42835

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 *