I'm running into issue with character encoding and I found the functions EBCDIC_STR
, ASCII_STR
in Db2
for z/OS. Are there similar function for Db2
for IBM i?
Starting with v7.2, there is a similar function in DB2 for i, it is CHAR
. It is not an exact replacement though. While EBCDIC_STR
returns a string in the system EBCDIC CCSID, and provides a UTF-16 encoding for unknown characters, CHAR
takes a string and converts it to a provided CCSID. CHAR
has no defined behavior for characters that cannot be converted to the new CCSID.
I believe you will have to use a CAST
specification in your SQL statement, specifying in it the desired CCSID, rather than using a built-in function.
This documentation page gives the syntax of a CAST specification, but it does not have a precisely relevant example. The DB2 for zOS CAST
page gives an example that should be the same on the i Series:
CAST(MYDATA AS CHAR(10) CCSID 367)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.