如何修改以下 SQL 以返回所选列的第一个字符的 EBCDIC(或者应该是 ASCI?)值>?
select
substr(PLAN_SLD_CHNL_CD,1,1)
from
GG60.SUSP_LOG_HDR SUSP_LOG_HDR
我对 DB2 非常陌生。
For the ASCII value, you can use the ASCII
function:
select ASCII(substr(PLAN_SLD_CHNL_CD,1,1))
from GG60.SUSP_LOG_HDR SUSP_LOG_HDR
Actually, this will also work:
select ASCII(PLAN_SLD_CHNL_CD)
from GG60.SUSP_LOG_HDR SUSP_LOG_HDR
But I prefer the first version, because it is more explicit about what it is doing (converting the first character to its ASCII code).
If you want to convert the string to EBCDIC, then use the EBCDIC_str()
function.