在 DB2 for iSeries 中从十六进制值到 EBCDIC [英] From Hex Value to EBCDIC in DB2 for iSeries
问题描述
我有这样的十六进制数据 (F9F9F9F9) 从查询中返回.当我从 IBM 链接检查时:https://www.ibm.com/support/knowledgecenter/en/SS2MB5_14.1.0/com.ibm.xlf141.bg.doc/language_ref/asciit.html
F9 = 9 和 F9 = 9
这里我应该得到 9999 的结果
我在一个表中有大约 1000 条这样的十六进制记录.
如何将此十六进制值转换为对应 EBCDIC 的值?
我试过了:
从表中选择 cast(col char(2) as codebase(37))
但是,它不起作用.此链接也不起作用:我不确定它是 cobol 代码还是 DB2 脚本.: http://www.ibmmainframeforum.com/db2/topic8785.htmlp>
请帮忙.谢谢.
select cast(col char(2) as codebase(37)) from table
正确的语法.
select cast(col as char(2) ccsid 37) as col from table
通常你不想一遍又一遍地这样做,所以也许只是改变表格.
ALTER TABLE mylib/Z1 ALTER COLUMN JOJOB SET DATA TYPE CHARACTER (10) CCSID 37 默认不为空
或者为只读数据在表上创建一个视图并从视图中读取.
创建视图表为从表中选择 cast(col as char(2) ccsid 37) as col
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.
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
这篇关于在 DB2 for iSeries 中从十六进制值到 EBCDIC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!