The VARBINARY function returns a VARBINARY representation of a string of any type.
The result of the function is 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.
If integer is not specified:
The actual length of the result is the minimum of the length attribute of the result and the actual length of the expression (or twice the length of the expression when the input is graphic data). If the length of the string-expression is greater than the length attribute of the result, truncation is performed. A warning (SQLSTATE 01004) 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, or the first input argument is a binary string and all the truncated bytes are hexadecimal zeroes.
Syntax alternatives: The CAST specification should be used to increase the portability of applications when the length is specified. For more information, see CAST specification.
SELECT VARBINARY('This is a VARBINARY') FROM SYSIBM.SYSDUMMY1