I have a db2 script that tries to insert some thai characters in a certain column of a table. The contents of that script is somewhat like this:
insert into thmsg (name, thvalue) values ('aaaa', 'ประเทศไทย');
I saved that script in UTF-8 format. Name of the file is thai.sql.
Then I started the DB2 Command Line Processor (CLP) and executed the following command : db2 -tvf thai.sql
Garbage values were inserted in the thmsg table for thvalue column.
But if I execute the same script via some editor, then correct value gets stored.
Because this works with a DB editor, but not from the command line, I'd guess that your command prompt is not utf8. What happens if you display the contents of the file using the command line without any editor?
Joined: Aug 24, 2009
I have a Windows machine. When i display the script file contents, I cannot see the thai characters. Instead I see the following garbled characters -
Is db2cmd not UTF-8?
Or is there any way to run this script without using an editor?
Joined: Apr 10, 2009
db2cmd is probably OK with utf8, the problem is that the Windows command prompt isn't. That's why you see the weird characters when you type the file.
So the command prompt is probably causing problems with db2cmd. According to what I just read (here) the solution is to change the code page with the chcp command and use a unicode compliant font (Lucida console is recommended).
I can't speak to this with great authority, since I use Linux most of the time. Take a look at the link and see what you think.