Thread: getting aroung chr(0)

getting aroung chr(0)

From
James Cloos
Date:
Is there a better way to do this:

 select (case
         when octet_length(n) > 0
         then chr(octet_length(n))::bytea
         else '\x00'
         end) || n from some_table;

some_table.n may contain values like ''::text,
but some_table.n is not null.

Obviously, a function like chr() which returns bytea
rather than text would be ideal, but lacking one....

Thanks,

-JimC
-- 
James Cloos <cloos@jhcloos.com>         OpenPGP: 0x997A9F17ED7DAEA6