If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Problem with umlauts in where-clause

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-25-10, 11:47
mclemens mclemens is offline
Registered User
 
Join Date: Mar 2010
Posts: 6
Problem with umlauts in where-clause

Hello all,

I have this problem with german umlauts in where clauses. Let's say I have a table "of" with a column "bar" and one row which is "Bär"

- SELECT bar FROM foo gives me the Result "Bär"
- SELECT bar FROM foo WHERE bar like 'B%' gives me the Result "Bär"
- SELECT bar FROM foo WHERE bar like 'Bä%' gives me nothing back

I use DB2 9.5.4 on AIX64, DB has Codepage 819, territory DE and Codeset ISO8859-1

Any idea?

Thanks in advance,
Michael
Reply With Quote
  #2 (permalink)  
Old 03-25-10, 12:30
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
It probably has more to do with your client and its locale, than with the WHERE clause.
Reply With Quote
  #3 (permalink)  
Old 03-25-10, 15:27
mclemens mclemens is offline
Registered User
 
Join Date: Mar 2010
Posts: 6
Quote:
Originally Posted by n_i View Post
It probably has more to do with your client and its locale, than with the WHERE clause.
I tried a lot there but no success. Any recommendations?
Reply With Quote
  #4 (permalink)  
Old 03-25-10, 15:33
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Quote:
Originally Posted by mclemens View Post
I tried a lot there but no success. Any recommendations?
What did you try?

For the third case, can you check what is on the db server? get a dynamic sql snapshot and lookup if the query has been passed as desired.
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #5 (permalink)  
Old 03-29-10, 03:49
mclemens mclemens is offline
Registered User
 
Join Date: Mar 2010
Posts: 6
On client side, I tried different combinations of $DB2CODEPAGE (819, 1208) and $LANG (en_US, de_DE, de_DE.UTF-8)

I also tried a dynamic sql snapshot as you suggested and have seeb the umlauts displayed correctly in there.

Michael
Reply With Quote
  #6 (permalink)  
Old 03-29-10, 04:05
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
I would run such a SELECT statement:
Code:
SELECT HEX('Bär') FROM sysibm.sysdummy1
Thus, you can see exactly which characters arrive at the DB2 side. You can double-check the code points, represented as hex numbers and make sure that indeed an 'ä' is received. You'll have to verify the code point in the code page of the DB2 server. If you don't find the correct character (which most of us here suspect), you have some conversion problem between your application and DB2.

If your application uses CLI/ODBC for the communication, you can also gather a CLI trace and verify in the trace which data is being transferred.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #7 (permalink)  
Old 03-29-10, 04:18
mclemens mclemens is offline
Registered User
 
Join Date: Mar 2010
Posts: 6
Quote:
Originally Posted by stolze View Post
I would run such a SELECT statement:
Code:
SELECT HEX('Bär') FROM sysibm.sysdummy1
Thus, you can see exactly which characters arrive at the DB2 side. You can double-check the code points, represented as hex numbers and make sure that indeed an 'ä' is received. You'll have to verify the code point in the code page of the DB2 server. If you don't find the correct character (which most of us here suspect), you have some conversion problem between your application and DB2.

If your application uses CLI/ODBC for the communication, you can also gather a CLI trace and verify in the trace which data is being transferred.
The query gives me back: 42C3A472
Honestly I don't know how to proceed from here on...

Last edited by mclemens; 03-29-10 at 06:52.
Reply With Quote
  #8 (permalink)  
Old 03-29-10, 16:10
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
"man ascii" on a decent Unix system shows that 0x42 is the code point for 'B' and 0x72 for 'r'. Thus, 0xC3A4 should be a UTF8 code point for 'ä'. You may want to double-check that this is correct for the code page that your database server is running on.

Also, you can apply the HEX() function to the data in your table. It should also return 0xC3A4 for all 'ä's.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #9 (permalink)  
Old 03-30-10, 04:18
mclemens mclemens is offline
Registered User
 
Join Date: Mar 2010
Posts: 6
After switching character encoding of my Gnome Terminal from UTF-8 to ISO-8859-1 qeuerying works now. The same query in an GUI application like DBVisualizer oder db2cc does not work.

Executing SELECT HEX('ä') FROM sysibm.sysdummy1 in Terminal (where everything's ok now) gives me E4 back.
Executing SELECT HEX('ä') FROM sysibm.sysdummy1 in db2cc gives me C3A4 back.

So the ä in my database must be saved as E4, right? What should I do now?

Thanks,
Michael
Reply With Quote
  #10 (permalink)  
Old 03-30-10, 06:51
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You'll have to figure out how to set the proper code page for "db2cc" and "DBVisualizer". A quick search turned up this: DB2 Control Center Code Page | db2ude
Code:
$ export DB2CODEPAGE=1208
$ db2cc
Which environment variable is used by DBVisualizer, I do not know.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #11 (permalink)  
Old 04-01-10, 07:40
mclemens mclemens is offline
Registered User
 
Join Date: Mar 2010
Posts: 6
Setting DB2CODEPAGE for db2cc doesn't work for me I still can't send umlauts correctly.

What works: select * from foo where hex(bar) like '42E4%'

But when typing 'ä', a C3A4 will be sent. I tried with db2cc and DBVisualizer under Windows and Linux on different Workstations. It makes me mad...
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On