DB2 V10 for Z/OS Unicode Table and JDBC gets -302 for Parameter that contains Unicode Characters

322 views Asked by At

I have a DB2 Table that is defined as Unicode table It contains a field defined as Char (35). Now i have a parameter that has the length 35 but contains a german umlaut so it needs more than 35 Byte. I get an SQLCODE -302 if i try to execute the Insert or Update statement. If i remove one character from the parameter variable it will work and reading the table will also return the german umlaut correctly. I tried it using SQuirreL with DB2 driver 3.64.82 and not a parameter but a string constant and it returned an SQLCode -404 which is the pendant to the -302 for String constants. Here is the sql statement i tried to execute in SQirreL SQL Client 3.4.0:

INSERT INTO LEA0001.VP_105 (Anlage_Zeitpunkt, Anlage_User, Aender_Zeitpunkt,
 Aender_User, V_Nr, lief_id_ref_nr, gueltig_bis_zp, gueltig_ab_zp,
 erstprod_termin,druckfreig_termin, ANF_SDB, IST_ERSTPROD_KW, pr_name, pr_strasse,
 pr_plz, pr_ort, pr_land) values (current timestamp, 'HUGO', current timestamp, '', 
48854, 2769, '9999-12-31 23:59:59.999999', '2014-11-25 15:40:36.395542',
'0001-01-01', '0001-01-01', 'N', 'N', 'Getränkeggggggggggggggggggggggggggg', '', '', '', '')

What i would like to know is if this is an error in the DB2 Driver or if there is a setting or a configuration for the driver that will make it work. To me it seems that right now the driver is comparing the number of bytes with the specified length of the field and then throwing that error because 36 > 35. But it should be obvious that for a Unicode table this can't be right.

Version information: In SQuirreL i use the IBM DB2 Net Driver and the db2jcc Driver Version 3.64.82 The DB is a Z/OS DB2 V10 Rel 1015

1

There are 1 answers

1
mustaccio On BEST ANSWER

CHAR(35) means 35 bytes, not characters. That has nothing to do with the driver, but with the way tables are defined in DB2. You need to account for the possible byte length of your character columns when you create the table.