2

I have embedded sql query to iseries in the Java program which is throwing the following error -

"[SQL0332] Character conversion between CCSID-id 1156 and 278 is not possible.".

I am facing this problem with only one library but not all.

Working query:

select * from SRBKTO where KOACNO=721

Not-working query:

select * from SRBKTO where KOACNO= '721' (This works for other libraries)

If I try to hit the query with conditional clause with quotes (String or int type), the error is thrown.

I do not have great knowledge on iSeries. What I understood is that there is a conversion problem for the character " ' " (as of now I guess only for that char) from the CCSID 1156 to 278.

I tried java API com.ibm.as400.access.AS400.setCcsid(1156) of jt400native jar to set the source CCSID to the connection object which didn't result in anything. Is it required to change the target CCSID? Can anyone please suggest a way to resolve this?

br3w5
  • 4,403
  • 5
  • 33
  • 42
PadmaReddy
  • 41
  • 2
  • The apostrophe character (" ' ") is x'7D' in both CCSID 278 and CCSID 1156. No "conversion" needed as such. But if KOACNO is any numeric data type, attempting to compare the column value with **any** quoted string doesn't make much sense. Why quote the value at all? – user2338816 Oct 10 '15 at 07:29

2 Answers2

0

If you use DSPFFD to display KOACNO field descriptions, you'll find that the codepage/charset is 1156 (Baltic). You may use CAST to convert the field in the query for your target charset.

Check what is the correct CCSID from the library that works. Example of casting below (assuming correct is 1146):

select * from SRBKTO where CAST(KOACNO AS CHAR(20) CCSID 1146) = '721'
Tuomas
  • 93
  • 9
0

The problem is the incompatibility between the CCSID of the database table and the CCSID of job that Java program is running under.

To Change the CCSID of the database table to match the job

CHGPF FILE([LIBRARY]/[FILE]) CCSID(278)

or CHGPF FILE([LIBRARY]/[FILE]) CCSID(*HEX) to have no conversion.

This seems the most likely one to change, as you say that other Libraries work fine.

Alternatively, to change the CCSID of the java program (if you're running interactively), to match the database table

CHGJOB CCSID(1156)

Or CHGJOB CCSID(*HEX) to have no conversion