在DB2 for iSeries中从十六进制值到EBCDIC [英] From Hex Value to EBCDIC in DB2 for iSeries
问题描述
我有从查询返回的类似HEX的数据(F9F9F9F9)。当我从IBM链接检查时:
> https://www.ibm.com/support/knowledgecenter/zh-CN/SS2MB5_14.1.0/com.ibm.xlf141.bg.doc/language_ref/asciit.html
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和F9 = 9
F9 = 9 and F9 = 9
在这里我应该得到9999
Here I should get result as 9999
我在一个表中拥有大约1000个十六进制记录。
I jhave around 1000 hex records like this in a table.
如何将十六进制值转换为与EBCDIC相对应的十六进制值?
How can I convert this hex values to it corrsponding EBCDIC ?
我尝试过:
select cast(col char(2) as codebase(37)) from table
但是,它不起作用。
此链接也不起作用:我不确定它是cobol代码还是DB2脚本。 : http://www.ibmmainframeforum.com/db2/topic8785.html
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
请帮助。
推荐答案
select cast(col char(2) as codebase(37)) from table
正确的语法中选择cast(col char(2)作为代码库(37))。
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
这篇关于在DB2 for iSeries中从十六进制值到EBCDIC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!