DB2 SQL Errors Codes and Error Messages and Warnings from Error -312 to -314

SQLServerF1

Error: DB2 SQL Error: SQLCODE=-312, SQLSTATE=42618, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
VARIABLE variable-name IS NOT
DEFINED OR NOT USABLE
Explanation: A variable is referenced in the SQL
statement, but it either is not defined or cannot be
used.
variable-name
The name of the variable that is referenced in
the statement.
One of the following conditions exists:
v The variable is not declared.
v The attributes of the variable are inconsistent with its
usage in the SQL statement.
v The host variable was specified in a dynamic SQL
statement. Host variables are not valid in dynamic
SQL statements.
v A host variable array is used in a context in which it
is unsupported.
v The variable appeared in one of the triggered SQL
statements in a CREATE TRIGGER statement. An
OLD transition variable cannot be modified in a
trigger body.
v The variable name is used in the body of an SQL
procedure (CREATE or ALTER PROCEDURE
statement), but the variable is not declared as an SQL
variable or parameter. The scope of the SQL variable
is the compound statement that contains the
declaration, including any compound statements that
are nested within that compound statement.
v The variable appeared in one of the key-expressions
of an index definition.
System action: The statement cannot be processed.
Programmer response: Do one of the following
solutions and try the request again:
v Verify that the program or SQL routine contains a
declaration for the variable. Verify that the variable
name in the SQL statement is spelled correctly.
v Verify that the attributes of the variable are
compatible with its use in the statement.
v Use parameter markers in a dynamic SQL statement
instead of host variables.
v Specify a NEW transition variable when the variable
is modified in a trigger.
v Declare the variable as an SQL variable or parameter
in the SQL procedure.
v Check the definition of the index and remove any
host variables that are specified.
SQLSTATE: 42618

Error: DB2 SQL Error: SQLCODE=-313, SQLSTATE=07001, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
-313 THE NUMBER OF HOST VARIABLES
SPECIFIED IS NOT EQUAL TO THE
NUMBER OF PARAMETER MARKERS
Explanation: The number of host variables specified in
the EXECUTE or OPEN statement is not the same as
the number of parameter markers (question marks)
appearing in the prepared SQL statement.
System action: The statement cannot be executed.
Programmer response: Correct the application
program so that the number of host variables specified
in the EXECUTE or OPEN statement is the same as the
number of parameter markers appearing in the
prepared SQL statement. The DESCRIBE INPUT SQL
statement can be used to determine the expected
number of input parameter markers.
SQLSTATE: 07001

Error: DB2 SQL Error: SQLCODE=-314, SQLSTATE=42714, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
THE STATEMENT CONTAINS AN
AMBIGUOUS HOST VARIABLE
REFERENCE
Explanation: A host variable used in the statement has
been defined more than once in this application
program causing confusion as to which host variable
defined should be used.
System action: The statement cannot be executed.
Programmer response: Make the host variable unique
or use qualifications to indicate which host variable
definition is to be used.
SQLSTATE: 42714

Above are list of DB2 SQL Errors and Warnings from Error -312 to -314 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 *