From: | Lance Peterson <heart8reaker(at)gmail(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: How to cast VARCHAR to BYTEA and vice-versa? |
Date: | 2005-03-14 17:31:20 |
Message-ID: | ec98d12d0503140931386fcdf4@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Christoph, is that recent functionality? I'm running 7.4 and I get:
ERROR: cannot cast type text to bytea
I get similar errors when trying to go the other direction.
On Mon, 14 Mar 2005 11:32:26 +0100, Christoph Haller <ch(at)rodos(dot)fzk(dot)de> wrote:
> "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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>
From | Date | Subject | |
---|---|---|---|
Next Message | Robert.Farrugia | 2005-03-14 17:53:03 | Inserting values in arrays |
Previous Message | Rod Taylor | 2005-03-14 13:56:22 | Re: Newbie wonder... |