473,491 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Bogus data type incompatible error SQLSTATE=22001?

I'm getting an odd error when I try to run a select statement in my
stored procedure. I need to select records where one field = the first
host variable, and the second host variable is between the values of
two other columns. The problem seems to occur when I check all three
conditions. When I have only two of the conditions, the procedure runs
to completion and I get a resultset.

Interestingly, I created a MS Access database with a link to the table
referenced below (via OLEDB). I can get many (if not all) of the
statements below to work in an Access query.

Can anyone help me figure out the true problem here? TIA!

The error message is:
A database manager error occurred.[IBM][CLI Driver][AS] SQL0303N A
value cannot be assigned to a host variable in the SELECT, VALUES, or
FETCH statement because the data types are not compatible.
SQLSTATE=22001

Here are the statements I've tried so far:
--SET stmADDR = 'SELECT ADDR.* FROM TESTFILES.ADDRESS AS ADDR WHERE
ADDR.ADR_POLICY_NO = ? AND (ADDR.ADR_THRU_SEQ_NO >= ' || POLSEQ || ')
AND (ADDR.ADR_FROM_SEQ_NO <= ' || POLSEQ || ')';
--SET stmADDR = 'SELECT ADDR.* FROM TESTFILES.ADDRESS AS ADDR WHERE
ADDR.ADR_POLICY_NO = ? AND (ADDR.ADR_THRU_SEQ_NO >= ' || POLSEQ || ')
AND (INT(ADDR.ADR_FROM_SEQ_NO) <= ' || POLSEQ || ')';
--SET stmADDR = 'SELECT ADDR.* FROM TESTFILES.ADDRESS AS ADDR WHERE
ADDR.ADR_POLICY_NO = ? AND ' || POLSEQ || ' BETWEEN
ADDR.ADR_FROM_SEQ_NO AND ADDR.ADR_THRU_SEQ_NO';
--SET stmADDR = 'SELECT ADDR.* FROM TESTFILES.ADDRESS AS ADDR WHERE
ADDR.ADR_POLICY_NO = ? AND ' || POLSEQ || ' <= ADDR.ADR_THRU_SEQ_NO AND
' || POLSEQ || ' >= ADDR.ADR_FROM_SEQ_NO';
--SET stmADDR = 'SELECT ADDR.* FROM TESTFILES.ADDRESS AS ADDR WHERE
ADDR.ADR_POLICY_NO = ? AND ' || POLSEQ || ' >= ADDR.ADR_FROM_SEQ_NO AND
' || POLSEQ || ' <= ADDR.ADR_THRU_SEQ_NO';
--SET stmADDR = 'SELECT ADDR.* FROM TESTFILES.ADDRESS AS ADDR WHERE
ADDR.ADR_POLICY_NO = ? AND INT(' || POLSEQ || ') >=
ADDR.ADR_FROM_SEQ_NO AND INT(' || POLSEQ || ') <=
ADDR.ADR_THRU_SEQ_NO';
--SET stmADDR = 'SELECT ADDR.* FROM (SELECT ADDR.* FROM
TESTFILES.ADDRESS AS ADDR WHERE ADDR.ADR_POLICY_NO = ? AND
ADDR.ADR_THRU_SEQ_NO >= ' || POLSEQ || ') AS ADDR WHERE
ADDR.ADR_POLICY_NO = ? AND ADDR.ADR_FROM_SEQ_NO <= ' || POLSEQ;
--SET stmADDR = 'SELECT ADDR.* FROM TESTFILES.ADDRESS AS ADDR WHERE
ADDR.ADR_POLICY_NO = ? AND ' || POLSEQ || ' BETWEEN
INT(ADDR.ADR_FROM_SEQ_NO) AND INT(ADDR.ADR_THRU_SEQ_NO)';
--SET stmADDR = 'SELECT ADDR.* FROM TESTFILES.ADDRESS AS ADDR WHERE
ADDR.ADR_POLICY_NO = ? AND INT(' || POLSEQ || ') BETWEEN
INT(ADDR.ADR_FROM_SEQ_NO) AND INT(ADDR.ADR_THRU_SEQ_NO)';
--SET stmADDR = 'SELECT tblADDRESS.* FROM (SELECT ADDR.* FROM
TESTFILES.ADDRESS AS ADDR WHERE ADDR.ADR_POLICY_NO = ? AND
ADDR.ADR_THRU_SEQ_NO >= ' || POLSEQ || ') AS tblADDRESS WHERE
tblADDRESS.ADR_FROM_SEQ_NO <= ' || POLSEQ;
--SET stmADDR = 'SELECT ADDR.* FROM TESTFILES.ADDRESS AS ADDR WHERE
ADDR.ADR_POLICY_NO = ? AND CHAR(' || POLSEQ || ') BETWEEN
CHAR(ADDR.ADR_FROM_SEQ_NO) AND CHAR(ADDR.ADR_THRU_SEQ_NO)';
--SET stmADDR = 'SELECT ADDR.* FROM TESTFILES.ADDRESS AS ADDR WHERE
' || POLSEQ || ' >= ADDR.ADR_FROM_SEQ_NO AND ' || POLSEQ || ' <=
ADDR.ADR_THRU_SEQ_NO AND ADDR.ADR_POLICY_NO = ?';
--SET stmADDR = 'SELECT ADDR.* FROM TESTFILES.ADDRESS AS ADDR WHERE
ADDR.ADR_POLICY_NO = ? AND (ADDR.ADR_THRU_SEQ_NO >= ?) AND
(ADDR.ADR_FROM_SEQ_NO <= ' || POLSEQ || ')';
--SET stmADDR = 'SELECT ADDR.* FROM TESTFILES.ADDRESS AS ADDR WHERE
ADDR.ADR_POLICY_NO = ? AND (ADDR.ADR_THRU_SEQ_NO >= ?) AND
(ADDR.ADR_FROM_SEQ_NO <= ?)';

-- Lines below work, but don't check all three conditions
--SET stmADDR = 'SELECT ADDR.* FROM TESTFILES.ADDRESS AS ADDR WHERE
ADDR.ADR_POLICY_NO = ? AND ADDR.ADR_THRU_SEQ_NO >= ' || POLSEQ;
--SET stmADDR = 'SELECT ADDR.* FROM TESTFILES.ADDRESS AS ADDR WHERE
ADDR.ADR_POLICY_NO = ? AND ADDR.ADR_FROM_SEQ_NO <= ' || POLSEQ;
--SET stmADDR = 'SELECT ADDR.* FROM TESTFILES.ADDRESS AS ADDR WHERE
' || POLSEQ || ' >= ADDR.ADR_FROM_SEQ_NO AND ' || POLSEQ || ' <=
ADDR.ADR_THRU_SEQ_NO';
PREPARE sADDR FROM stmADDR;
OPEN cADDR USING POLICYNO;

Additional Info:
I am using DB2 UDB v 8.1 running on an iSeries model 270.
I coded and tested my stored procedure using the DB2 Development
Center.

Nov 12 '05 #1
0 4888

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5246
by: Bj?rn Terje Svennes | last post by:
I'm using ODBC to interface a Microsoft SQL Server 2000. One of the operations involves placing files within BLOBs. I'm using the image data type for this purpose. Most of the time this works okey,...
10
49545
by: joel.brewster | last post by:
We have a VB6 application using ADO version 2.5 and I am receiving a " CLI0109E String data right truncation. SQLSTATE=22001" error when I execute the rs.UpdateBatch method. I have determined...
1
60875
by: gimme_this_gimme_that | last post by:
When you get the message : String data right truncation. SQLSTATE=22001 What is usually the source of the problem? Might a null value assigned get a PreparedStatement's setString method be...
2
6602
by: roha_78 | last post by:
COM.ibm.db2.jdbc.DB2Exception: CLI0109E String data right truncation. SQLSTATE=22001 at com.ibm.ejs.container.ContainerManagedBeanO.postCreate(ContainerManagedBeanO.java:500) at...
2
4864
by: roha_78 | last post by:
i am using the follwing code to connect to db2 : java.sql.Connection connection = null; java.sql.ResultSet rs = null; ExperimentJDBCHelperBean jdbchelper = new ExperimentJDBCHelperBean();...
1
4830
by: jrs_14618 | last post by:
Hello All, This post is essentially a reply a previous post/thread here on this mailing.database.myodbc group titled: MySQL 4.0, FULL-TEXT Indexing and Search Arabic Data, Unicode I was...
0
3169
by: priyankas | last post by:
I am getting this error when doing a SELECT statement . COM.ibm.db2.jdbc.DB2Exception Message is: CLI0 :109E String data right truncation. SQLSTATE=22001 Can anyone help me out with this?
1
8716
by: Justin | last post by:
I have a function that has a varchar about 300 characters. When I run the insert command from a function I receive the error SQL0433N - Value .... is too long SQLSTATE=22001. If I run the...
0
6524
by: Brenda | last post by:
We are on DB2, AIX fixpak 14 This error happens when running PeopleSoft PeopleCode Application Engine process. I have checked other posts out here and it seems like others who have reported...
0
7115
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6978
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7154
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7360
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
280
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.