问题
I have HEX data like this (F9F9F9F9) returned from a query. When I checked from IBM link : https://www.ibm.com/support/knowledgecenter/en/SS2MB5_14.1.0/com.ibm.xlf141.bg.doc/language_ref/asciit.html
F9 = 9 and F9 = 9
Here I should get result as 9999
I jhave around 1000 hex records like this in a table.
How can I convert this hex values to it corrsponding EBCDIC ?
I tried like :
select cast(col char(2) as codebase(37)) from table
How ever, its not working. THis link is also not working: I'm not sure if its a cobol code or DB2 script. : http://www.ibmmainframeforum.com/db2/topic8785.html
Please help.Thanks.
回答1:
select cast(col char(2) as codebase(37)) from table
Correct Syntax.
select cast(col as char(2) ccsid 37) as col from table
Generally you don't want to do this over and over so maybe just alter the table.
ALTER TABLE mylib/Z1 ALTER COLUMN JOJOB SET DATA TYPE CHARACTER (
10) CCSID 37 NOT NULL WITH DEFAULT
Or create a view over the table for read only data and read from the view.
create view tablev as
select cast(col as char(2) ccsid 37) as col from table
来源:https://stackoverflow.com/questions/48265732/from-hex-value-to-ebcdic-in-db2-for-iseries