DB2 query results in Hex format — Need Character/String

隐身守侯 提交于 2019-12-02 18:15:47

问题


I have a query that I can run on a DB2 table using my python SQL tester, and it returns the string values I'm looking for.
However, when I run it directly on my database it returns a hex value. Any help in getting the results as a character string would be greatly appreciated!
Here is the field definition:

ORCTL      CCDATA         243      A   14  256 Order Control File Data 

My query on the iSeries is:

select ccdata from ORCTL where ccctlk = 'BUYRAK'

回答1:


Using your query, you can cast a string with another CCSID, eg :

select cast(ccdata as char(14) CCSID 37) from ORCTL where ccctlk = 'BUYRAK'



回答2:


My guess is that it isn't returning hex...

Rather it's returning EBCDIC.

Your column is probably tagged with CCSID 65535, which tells the system not to translate it.

The right way to fix this issue, is to make sure the column is tagged with the appropriate CCSID; for example, 37 for US English.

The alternative, is to look for a "force translate" option in the settings of driver you're using.



来源:https://stackoverflow.com/questions/40727461/db2-query-results-in-hex-format-need-character-string

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