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 > Help need on Character conversion

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-24-04, 08:08
mailar mailar is offline
Registered User
 
Join Date: Nov 2004
Posts: 6
Post Help need on Character conversion

Hi Friends,
Can anyone tell me how to perform conversion of string from one character set to another in DB2. I mean do we have anything equivalent to CONVERT function of Oracle in DB2.
Reply With Quote
  #2 (permalink)  
Old 11-24-04, 08:27
J Petruk J Petruk is offline
Registered User
 
Join Date: Mar 2004
Location: Toronto, ON, Canada
Posts: 513
Quote:
Originally Posted by mailar
Hi Friends,
Can anyone tell me how to perform conversion of string from one character set to another in DB2. I mean do we have anything equivalent to CONVERT function of Oracle in DB2.
What type of conversion? What does CONVERT in Oracle do?
__________________
--
Jonathan Petruk
DB2 Database Consultant
Reply With Quote
  #3 (permalink)  
Old 11-24-04, 10:11
dbamota dbamota is offline
Registered User
 
Join Date: Sep 2003
Posts: 237
please look at TRANSLATE function
__________________
mota
Reply With Quote
  #4 (permalink)  
Old 11-24-04, 12:20
przytula przytula is offline
Registered User
 
Join Date: Nov 2004
Posts: 374
convert

convert is being used to translate characters from one character set to another. db2 does not have a similar function. ccsid is flagged at column level when you create the table. there are automatic convertion in known relations in the same character group.
there is no function to convert a ccsid.
translate only does a replacement of a character by another character but in the same character set.
Best Regards, Guy Przytula
__________________
Best Regards, Guy Przytula
DB2/ORA/SQL Services
DB2 DBA & Advanced DBA Certified
DB2 Dprop Certified
http://users.skynet.be/przytula/dbss.html
Reply With Quote
  #5 (permalink)  
Old 11-24-04, 16:49
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
If you do an export and import, DB2 will perform the character set converstion if they are compatible.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #6 (permalink)  
Old 11-25-04, 01:56
mailar mailar is offline
Registered User
 
Join Date: Nov 2004
Posts: 6
CONVERT
Syntax
convert::=CONVERT(attribute, dest_char_set, source_char_set)
Purpose
CONVERT converts a character string specified in an operator attribute from one
character set to another. The data type of the returned value is VARCHAR2.
 The attribute1 argument is the value to be converted. It can of the data types
CHAR and VARCHAR2.
 The dest_char_set argument is the name of the character set to which
attribute1 is converted.
 The source_char_set argument is the name of the character set in which
attribute1 is stored in the database. The default value is the database character
set.
Both the destination and source character set arguments can be either literals or
columns containing the name of the character set. For complete correspondence in
character conversion, the destination character set must contain a representation of all
the characters defined in the source character set. When a character does not exist in
the destination character set, it is substituted with a replacement character.
Replacement characters can be defined as part of a character set definition.

Example
The following example illustrates character set conversion by converting a Latin-1
string to ASCII. The result is the same as importing the same string from a
WE8ISO8859P1 database to a US7ASCII database.
SELECT CONVERT('Ä Ê Í Õ Ø A B C D E ', 'US7ASCII', 'WE8ISO8859P1')
FROM DUAL;
CONVERT('ÄÊÍÕØABCDE'
---------------------
A E I ? ? A B C D E ?

Also , TRANSLATE function does not do character set conversion . It just translates one character to another of the same character set and not of different character set
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