• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cannot insert chinese/thai characters in db2 through script

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Any idea how can I get it working via DB2 CLP?
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which command line, Linux or Windows?

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?

 
Rahul Vhatkar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Alan Hampson
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic