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

Поиск
Список
Период
Сортировка
От Christoph Haller
Тема Re: How to cast VARCHAR to BYTEA and vice-versa?
Дата
Msg-id 4235683A.6D2CA65A@rodos.fzk.de
обсуждение исходный текст
Ответ на How to cast VARCHAR to BYTEA and vice-versa?  ("Moran.Michael" <Michael.Moran@IGT.com>)
Ответы Re: How to cast VARCHAR to BYTEA and vice-versa?  (Lance Peterson <heart8reaker@gmail.com>)
Список 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


В списке pgsql-sql по дате отправления:

Предыдущее
От: PFC
Дата:
Сообщение: Re: Newbie wonder...
Следующее
От: pginfo
Дата:
Сообщение: Re: lower and unicode