getting aroung chr(0)

From: James Cloos <cloos(at)jhcloos(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: getting aroung chr(0)
Date: 2020-10-09 20:01:27
Message-ID: m3zh4vxj6w.fsf@carbon.jhcloos.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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(at)jhcloos(dot)com> OpenPGP: 0x997A9F17ED7DAEA6

Browse pgsql-sql by date

  From Date Subject
Next Message Iuri Sampaio 2020-10-10 02:58:15 total and partial sums in the same query??
Previous Message Tatsuo Ishii 2020-10-09 04:40:21 Re: send query in background