Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do I INSERT long VARCHAR in DB2?

843840May 15 2002 — edited May 17 2002
I have a field in DB2 defined as VARCHAR and it is 1024 bytes long. When I try to insert data into this file I get an SQLCODE of -102 (String constant is to long). After researching on why it's happening I found out that DB2 has Insert restriction. One can only insert 254 bytes in VARCHAR. I have String that is 1024 bytes long. How do I insert this String? I know what I need to do, but I am mainframe programmer and have very little knowledge on how to do this in Servlet. I am trying to learn new technology. All your help will be appreciated. I have a code that I will do in Mainframe, but I need it to be Java Servlet.
I need to calculate length of string and insert first 254 bytes and then have a loop to Update this field till there is nothing left. Can anyone help me out? I will be really thankful to them. Thank you.

INSERT INTO my.table1
COLUMNS (LONG_COL)
VALUES (first 254 bytes of LONG_COL);

UPDATE my.table1
SET LONG_COL = LONG_COL || remaining bytes of LONG_COL,
WHERE key = key value;


Thank you for your help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 14 2002
Added on May 15 2002
3 comments
1,177 views