468,133 Members | 1,228 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,133 developers. It's quick & easy.

How to determine field length in an unicode database

I have created a db2 8.1 database with codeset UTF-8.
I thought the database was able to handle field legths as characters and not
as byte data then.
But I'm getting an error when inserting a 20 characters string containing
non ASCII characters
into a character 20 field.

Is there a good way to handle this, or do I have to estimate a field length
?
Poul
Nov 12 '05 #1
1 4567
Poul Møller Hansen wrote:
I have created a db2 8.1 database with codeset UTF-8.
I thought the database was able to handle field legths as characters and not
as byte data then.
But I'm getting an error when inserting a 20 characters string containing
non ASCII characters
into a character 20 field.

Is there a good way to handle this, or do I have to estimate a field length
?
Poul


DB2 always uses bytes rather than characters for varchar. So a
varchar(20) is twenty bytes rather than 20 characters. Since one UTF-8
character can be 4 bytes long, use varchar(80) for the column definition.
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by wolfgang haefelinger | last post: by
5 posts views Thread by DotNetJunkies User | last post: by
10 posts views Thread by Marc Jennings | last post: by
4 posts views Thread by andyoye | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.