Re: How to trim Bytea fields

From: Joe Conway <mail(at)joeconway(dot)com>
To: Howard Cole <howardnews(at)selestial(dot)com>
Cc: 'PgSql General' <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to trim Bytea fields
Date: 2005-11-22 15:23:53
Message-ID: 43833809.1070905@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Howard Cole wrote:
> Hi,
>
> I have an bytea field that contains data with a lot of trailing blank
> space composed of multiple '\000' zero bytes. Does anyone know of a
> quick SQL fix to trim these bytes from the data?

trim() will remove '\000' bytes from both ends -- would that work for you?

select trim('\\000'::bytea from '\\00012\\00034\\000\\000'::bytea);
btrim
----------
12\00034
(1 row)

Joe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2005-11-22 15:47:53 Re: problem with GRANT postgres 8.0.4
Previous Message Richard Huxton 2005-11-22 15:22:36 Re: problem with GRANT postgres 8.0.4