DB2 Scalar functions - BINARY
The BINARY function returns a fixed-length binary string representation of a string of any data type.
The schema is SYSIBM.
If string-expression is an empty string and the integer argument is not specified, an error is returned (SQLSTATE 42815).
The result of the function is a BINARY. If the first argument can be null, the result can be null; if the first argument is null, the result is the null value.
The actual length is the same as the length attribute of the result. If the length of string-expression that is converted to a binary string is less than the length attribute of the result, the result is padded with hexadecimal zeros up to the length of the result. If the length of string-expression that is converted to a binary string is greater than the length attribute of the result, truncation occurs.
A warning (SQLSTATE 01004) is returned in the following situations:
SELECT BINARY('',1) FROM SYSIBM.SYSDUMMY1
SELECT BINARY('KBH',5) FROM SYSIBM.SYSDUMMY1
SELECT BINARY('KBH') FROM SYSIBM.SYSDUMMY1
SELECT BINARY('KBH ',3) FROM SYSIBM.SYSDUMMY1
SELECT BINARY('KBH 93',3) FROM SYSIBM.SYSDUMMY1