DB2 SQL Errors Codes and Error Messages and Warnings from Error -303 to -305

SQLServerF1

Error: DB2 SQL Error: SQLCODE=-303, SQLSTATE=42806, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
A VALUE CANNOT BE ASSIGNED TO
OUTPUT HOST VARIABLE NUMBER
position-number BECAUSE THE DATA
TYPES ARE NOT COMPARABLE
Explanation: A CALL, FETCH, SELECT, VALUES
INTO, or SET statement with an output host variable
could not be performed because the data type of a
variable was not compatible with the data type of the
corresponding SELECT, VALUES INTO, or SET
statement list element.
position-number
Location of the host variable value in the
output SQLDA.
The values of the output host variable and the
corresponding list element must be in one of the
following categories:
v Both must be numbers.
v Both must be character strings, unless you are using
Unicode.
v Both must be graphic strings, unless you are using
Unicode.
v Both must be row IDs.
v Both must be binary strings, or one can be BINARY
or VARBINARY, and the other can be FOR BIT
DATA.
In addition, for datetime or timestamp values, the host
variable must be a character string variable with a
correct length.
System action: The statement was not executed. No
data is retrieved.
Programmer response: Verify that table definitions are
current and that the host variable has the correct data
type.
SQLSTATE: 42806

Error: DB2 SQL Error: SQLCODE=-304, SQLSTATE=22003, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
A VALUE WITH DATA TYPE data-type1
CANNOT BE ASSIGNED TO A HOST
VARIABLE BECAUSE THE VALUE IS
NOT WITHIN THE RANGE OF THE
HOST VARIABLE IN POSITION
position-number WITH DATA TYPE
data-type2
Explanation: A CALL, FETCH, SELECT, VALUES
INTO, or SET assignment statement with a host
variable list or structure in position number
position-number failed because the host variable with
data type data-type2 was not large enough to hold the
retrieved value with data type data-type1.
System action: The statement cannot be executed. No
data was retrieved. If the statement was a FETCH, the
cursor remains open.
Programmer response: Verify that table definitions are
current, and that the host variable has the correct data
type. See the explanation for SQLCODE -405 for ranges
of SQL data types.
SQLSTATE: 22003

Error: DB2 SQL Error: SQLCODE=-305, SQLSTATE=22002, SQLERRMC=TBSPACEID=, TABLEID=, COLNO=, DRIVER=
THE NULL VALUE CANNOT BE
ASSIGNED TO OUTPUT HOST
VARIABLE NUMBER position-number
BECAUSE NO INDICATOR VARIABLE
IS SPECIFIED
Explanation: A FETCH, SELECT, VALUES INTO, or
SET assignment statement resulted in the retrieval of a
null value to be inserted into the output host variable,
designated by entry number ‘position-number’ of the
output SQLDA, for which no indicator variable was
provided. An indicator variable must be supplied if a
column returns a null value.
System action: The statement cannot be executed. No
data was retrieved.
Programmer response: Examine the definition of the
table that is the object of the statement and correct the
application program to provide indicator variables for
all host variables into which null values can be
retrieved. This includes host variables for columns
which can contain null values and host variables which
receive the results of aggregate functions whose result
table could be empty.
SQLSTATE: 22002

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