BLOB

The BLOB function returns a BLOB representation of a string of any type or of a row ID type.

Read syntax diagram
>>-BLOB(string-expression-+------------+-)---------------------><
                          '-,--integer-'     

The schema is SYSIBM.

string-expression
An expression that returns a value that is a built-in character string, graphic string, binary string, or a row ID type.
integer
An integer value that specifies the length attribute of the resulting binary string. The value must be an integer between 1 and the maximum length of a BLOB.

Do not specify integer if string-expression is a row ID type.

If you do not specify integer and string-expression is an empty string constant, the length attribute of the result is 1, and the result is an empty string. Otherwise, the length attribute of the result is the same as the length attribute of string-expression, except when the input is graphic data. In this case, the length attribute of the result is twice the length of expression.

The result of the function is a BLOB.

The result can be null; if the first argument is null, the result is the null value.

The actual length of the result is the minimum of the length attribute of the result and the actual length of string-expression (or twice the length of string-expression when the input is graphic data). If the length of string-expression is greater than the length attribute of the result, truncation is performed. A warning is returned unless the first input argument is a character string and all the truncated characters are blanks, or the first input argument is a graphic string and all the truncated characters are double-byte blanks.

Example 1: The following function returns a BLOB for the string 'This is a BLOB'.
   SELECT BLOB('This is a BLOB')
     FROM SYSIBM.SYSDUMMY1;
Example 2: The following function returns a BLOB for the large object that is identified by locator myclob_locator.
   SELECT BLOB(:myclob_locator)
     FROM SYSIBM.SYSDUMMY1;
Example 3: Assume that a table has a BLOB column named TOPOGRAPHIC_MAP and a VARCHAR column named MAP_NAME. Locate any maps that contain the string 'Engles Island' and return a single binary string with the map name concatenated in front of the actual map.
   SELECT BLOB(MAP_NAME || ':  ') || TOPOGRAPHIC_MAP
     FROM ONTARIO_SERIES_4
     WHERE TOPOGRAPHIC_MAP LIKE BLOB('%Engles Island%')