DB2 SQL Errors Codes and Error Messages and Warnings from Error -300 to -302

SQLServerF1

Error: DB2 SQL Error: SQLCODE=-300, SQLSTATE=22024, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
THE STRING CONTAINED IN HOST
VARIABLE OR PARAMETER
position-number IS NOT
NUL-TERMINATED
Explanation: A host variable or parameter is invalid.
Its entry in the SQLDA is indicated by position-number.
The host variable or parameter is a C string variable
that is one of the following:
v Used as an input parameter to a stored procedure or
function.
v Returned as an output parameter from a stored
procedure or function.
v Referenced as an input variable in an embedded SQL
statement.
v Used to provide a value for a parameter marker of a
dynamic SQL statement.
If the data type of the variable is character string, it is
invalid because it does not include X’00’. If the data
type of the variable is graphic string, it is invalid
because it does not include X’0000′.
System action: The statement cannot be executed.
Programmer response: Append a NUL-terminator to
the end of the string.
SQLSTATE: 22024

Error: DB2 SQL Error: SQLCODE=-301, SQLSTATE=42895, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
THE VALUE OF INPUT HOST
VARIABLE OR PARAMETER NUMBER
position-number CANNOT BE USED AS
SPECIFIED BECAUSE OF ITS DATA
TYPE
Explanation: DB2 received data that could not be used
as specified in the statement because its data type is
incompatible with the requested operation.
The position-number identifies either the host variable
number (if the message is issued as a result of an
INSERT, UPDATE, MERGE, DELETE, SELECT, VALUE
INTO, or SET assignment statement), or the parameter
number (if the message is issued as the result of a
CALL statement, or the invocation of a function).
System action: The statement cannot be executed.
Programmer response: Correct the application
program, function or stored procedure. Ensure that the
data type of the indicated input host variable or
parameter in the statement is compatible with the way
it is used.
SQLSTATE: 42895

Error: DB2 SQL Error: SQLCODE=-302, SQLSTATE=22003, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
THE VALUE OF INPUT VARIABLE OR
PARAMETER NUMBER position-number
IS INVALID OR TOO LARGE FOR
THE TARGET COLUMN OR THE
TARGET VALUE
Explanation: DB2 received data that was invalid or
too large to fit in the corresponding column of the table
or the corresponding target value. The position-number
identifies either the host variable number (if the
message is issued as a result of an INSERT, UPDATE,
MERGE, DELETE, SELECT, VALUES INTO, or SET
assignment statement), or the parameter number (if the
message is issued as the result of a CALL statement or
the invocation of a function).
One of the following occurred:
v The column is defined as a string and the host
variable or parameter contains a string that is too
long for the column.
v The column is defined as numeric and the host
variable or parameter contains a numeric value too
large for the definition of the column.
v The host variable is defined as decimal, but contains
invalid decimal data.
v The target value is a string constant and the host
variable or parameter contains a string that is too
long for the target value.
v The target value is a numeric constant and the host
variable or parameter contains a numeric value that
is too large for the target value.
System action: The statement cannot be executed.
Programmer response: Correct the application
program, function or stored procedure. Check the
column type and length of the value or the data type
and contents of the input host variable or parameter
position-number. Ensure that the value of the host
variable or parameter will fit in the column or contains
valid decimal data. Valid decimal data is a System/370
packed decimal number.
SQLSTATE: 22003 if number too large for target; 22001
otherwise.

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