DB2 Scalar functions - VARBINARY
The VARBINARY function returns a VARBINARY (varying-length binary string) representation of a string of any data type.
The schema is SYSIBM.
If the length attribute of string-expression is zero and the integer argument is not specified, the length attribute of the result is 1.
The result of the function is a VARBINARY. 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 of the result is the minimum of the length attribute of the result and the actual length in bytes of the string-expression. 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 VARBINARY('',1) FROM SYSIBM.SYSDUMMY1
SELECT VARBINARY('KBH',5) FROM SYSIBM.SYSDUMMY1
SELECT VARBINARY('KBH') FROM SYSIBM.SYSDUMMY1
SELECT VARBINARY('KBH ',3) FROM SYSIBM.SYSDUMMY1
SELECT VARBINARY('KBH 93',3) FROM SYSIBM.SYSDUMMY1