![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, I'm setting up a new DB2 database on a Red Hat Enterprise Linux 5.5 server. For the first time, I set set it up using UTF-8, thinking that the time has come for this with DB2. But now I'm seeing strange situations like: CREATE TABLE foo (x VARCHAR(5)); INSERT INTO foo VALUES('XXåXX'); SQL0433N Value "XXåXX" is too long. SQLSTATE=22001 INSERT INTO foo VALUES('XXåX') SELECT * FROM foo X ----- XXåX db2 "SELECT LENGTH(x) FROM foo" 1 ----------- 5 This is absurd. I have tried various combinations of CREATE DATABASE specifications without luck. Does DB2 still not support UTF-8 properly? Do I need to stay with latin1 databases for things to work as everyone would expect, or are there somewhat sane work-arounds which can be employed? |
#3
| |||
| |||
|
|
Op 10-09-10 22:17, Troels Arvin schreef: Hello, I'm setting up a new DB2 database on a Red Hat Enterprise Linux 5.5 server. For the first time, I set set it up using UTF-8, thinking that the time has come for this with DB2. But now I'm seeing strange situations like: CREATE TABLE foo (x VARCHAR(5)); INSERT INTO foo VALUES('XXåXX'); SQL0433N Value "XXåXX" is too long. SQLSTATE=22001 INSERT INTO foo VALUES('XXåX') SELECT * FROM foo X ----- XXåX db2 "SELECT LENGTH(x) FROM foo" 1 ----------- 5 This is absurd. I have tried various combinations of CREATE DATABASE specifications without luck. Does DB2 still not support UTF-8 properly? Do I need to stay with latin1 databases for things to work as everyone would expect, or are there somewhat sane work-arounds which can be employed? i think your question was answered here: http://bytes.com/topic/db2/answers/6...multibyte-data |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
Does DB2 still not support UTF-8 properly? Do I need to stay with latin1 databases for things to work as everyone would expect, or are there somewhat sane work-arounds which can be employed? |
#6
| |||
| |||
|
|
Hello, I'm setting up a new DB2 database on a Red Hat Enterprise Linux 5.5 server. For the first time, I set set it up using UTF-8, thinking that the time has come for this with DB2. But now I'm seeing strange situations like: CREATE TABLE foo (x VARCHAR(5)); INSERT INTO foo VALUES('XXåXX'); * SQL0433N *Value "XXåXX" is too long. *SQLSTATE=22001 INSERT INTO foo VALUES('XXåX') SELECT * FROM foo X * * ----- XXåX db2 "SELECT LENGTH(x) FROM foo" 1 * * * * * ----------- * * * * * 5 This is absurd. I have tried various combinations of CREATE DATABASE specifications without luck. Does DB2 still not support UTF-8 properly? Do I need to stay with latin1 databases for things to work as everyone would expect, or are there somewhat sane work-arounds which can be employed? -- Troels |
#7
| |||
| |||
|
|
What should work is to make the VARCHAR columns larger, but to use check constraints: [...] |
#8
| |||
| |||
|
|
Henrik Loeser wrote: What should work is to make the VARCHAR columns larger, but to use check constraints: [...] Thanks. Yes, but this would entail a large amount of code inspection and query/DDL rewrites - which is not an option. -- Troels |
#9
| |||
| |||
|
|
Hi Troels, Does DB2 still not supportUTF-8properly? Do I need to stay with latin1 databases for things to work as everyone would expect, or are there somewhat sane work-arounds which can be employed? In a unicode database the length of a (VAR)CHAR does not represent the number of characters, but the number of bytes. |
#10
| |||
| |||
|
|
On Sep 11, 2:47*am, Helmut Tessarek <tessa... (AT) evermeet (DOT) cx> wrote: Hi Troels, Does DB2 still not supportUTF-8properly? Do I need to stay with latin1 databases for things to work as everyone would expect, or are there somewhat sane work-arounds which can be employed? In a unicode database the length of a (VAR)CHAR does not represent the number of characters, but the number of bytes. Is it generally defined this way or is it a db2 definition? Anyhow, I'm wondering whether it has been discussed to introduce a string type that "hides" the additional space requirements? I.e. if I declare a column as new_varchar(3) it would reserve up to 12 bytes. I can understand the rational by to days construction, but in many situations one have a database where the size of the data is small, but there are a lot of standard domains (say street address for example). These domains will require tweaking (multiply size and add check constraints as Henrik proposed). /Lennart |
![]() |
| Thread Tools | |
| Display Modes | |
| |