From Hex Value to EBCDIC in DB2 for iSeries

纵然是瞬间 提交于 2019-12-08 13:22:30

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!