How to convert String to BLOB in ESQL?

2019-07-30 15:04发布

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).

2条回答
ゆ 、 Hurt°
2楼-- · 2019-07-30 15:11

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

查看更多
你好瞎i
3楼-- · 2019-07-30 15:17

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.

查看更多
登录 后发表回答