ASCII NUL characters (solution)
Suppose we have database with no tables, external tables, UDFs, ...
There is only one procedure with one VARCHAR output parameter.
When you execute this procedure, it will return string
consisting of 5 ASCII NUL characters (binary zeroes).
What is in the body of this SP ?
When assigning shorter string to longer CHAR field
(or to CHAR variable, or CASTing it to CHAR),
IB/FB pads it with "blanks". The character used for padding is not
always the space; in fact, it depends on character set used.
The character set OCTETS is intended to store binary data,
and so its padding character is - binary zero.
CREATE PROCEDURE proc
RETURNS (str VARCHAR(10)) AS
BEGIN
str = CAST('' AS CHAR(5) CHARACTER SET OCTETS);
END
Ivan Prenosil (2002)