Re: How to cast VARCHAR to BYTEA and vice-versa?

From: Christoph Haller <ch(at)rodos(dot)fzk(dot)de>
To: "Moran(dot)Michael" <Michael(dot)Moran(at)IGT(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to cast VARCHAR to BYTEA and vice-versa?
Date: 2005-03-14 10:32:26
Message-ID: 4235683A.6D2CA65A@rodos.fzk.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Moran.Michael" wrote:
>
> Hello all,
>
> I have a table with a VARCHAR column that I need to convert to a BYTEA.
>
> How do I cast VARCHAR to BYTEA?
>
> The following doesn't seem to work as it yields the 'cannot cast varchar to
> bytea' error message:
>
> varchar_data::bytea
>
> On the same topic, how do I do the reverse, that is, how to I cast from
> BYTEA back to VARCHAR?
>
> Thanks,
> -Michael Moran
>
>
As far as I remember
varchar_data::TEXT::BYTEA
works. Vice versa dto.
Be aware BYTEA data may contain character codes
unconvertable to VARCHAR, especially '\0'.

Regards, Christoph

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Miroslav Šulc 2005-03-14 10:43:01 Re: lower and unicode
Previous Message pginfo 2005-03-14 09:40:12 Re: lower and unicode