How to convert String to BLOB in ESQL?

China☆狼群 提交于 2019-12-11 04:43:06

问题


It should be as simple as

  SET OutputRoot.BLOB.BLOB = CAST(MYSTRING AS BLOB);

But when I do that IIB Throws an error

An attempt was made to cast the character string ''ABC'' to a byte string, but the string was of the wrong format. There must be an even number of hexadecimal digits (0-9, a-f, A-F).


回答1:


In my case I needed to change it to AS BLOB CCSID 1208 I need to read up on what CCSID means now.




回答2:


As you figured out, the Syntax of the CAST-function you need here is

CAST( <source_expression> AS <DataType> CCSID <expression> )

so in your code it is

CAST( MYSTRING AS BLOB CCSID 1208 )

The CCSID parameter is used only for conversions to or from one of the string data types. Use the CCSID parameter to specify the code page of the source or target string. [Source]

So with the Coded character set identifiers (CCSID) you define the code page. For example 1208 is the CCSID for UTF-8 with IBM PUA. You can see a list of IBMs CCSIDs here.

If you want to get informations on this topic in more detail you can check the IIB documentation for Version 9.0.0 or Version 10.0.0.



来源:https://stackoverflow.com/questions/41402177/how-to-convert-string-to-blob-in-esql

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