SQL CONVERT Function is used to convert a string from one character set to another character set. Oracle CONVERT Function syntax and examples are listed below.
SQL CONVERT Function Syntax
SELECT CONVERT(string, character_set_to, [character_set_from]) FROM table_name;
In the above Oracle CONVERT Function Syntax:-
- ‘string’ is the string to be converted
- ‘character_set_to’ is the character set to which the string is to be converted
- ‘character_set_from’ is the character set from which the string is to be converted
A character set for Oracle CONVERT Function can be any one of the following:
Character Set | Explanation |
US7ASCII | US 7-bit ASCII character set |
WE8DEC | West European 8-bit character set |
WE8HP | HP West European Laserjet 8-bit character set |
F7DEC | DEC French 7-bit character set |
WE8EBCDIC500 | IBM West European EBCDIC Code Page 500 |
WE8PC850 | IBM PC Code Page 850 |
WE8ISO8859P1 | ISO 8859-1 West European 8-bit character set |
US7ASCII | US 7-bit ASCII character set |
SQL CONVERT Function – Converting to US7ASCII from WE8EBCDIC500 Example
Oracle CONVERT Function is used with the SQL SELECT Statement for conversion.
For example, the Oracle CONVERT Function query below returns the value converted in ‘US7ASCII’ character set.
SELECT CONVERT('A B C D E Ä Ê Í Õ Ø', 'US7ASCII', 'WE8EBCDIC500') FROM dual;
Will return ‘?a?a?a?a?D?-?o?N?Q’
SQL CONVERT Function – Converting to US7ASCII from WE8HP Example
the Oracle CONVERT Function query below returns the value converted in ‘US7ASCII’ character set.
SELECT CONVERT('A B C D E Ä Ê Í Õ Ø', 'US7ASCII', 'WE8HP') FROM dual;
Will return ‘A B C D E a o e i A’