Re: how to read bytea field

From: Richard Huxton <dev(at)archonet(dot)com>
To: marcelo Cortez <jmdc_marcelo(at)yahoo(dot)com(dot)ar>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: how to read bytea field
Date: 2007-01-24 15:31:31
Message-ID: 45B77BD3.3020705@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

marcelo Cortez wrote:
> ok my mistake ,
>
> insert into pblfield( id_ , value_field )
> values(1 ,encode(E'\\000\\001', 'escape') ::bytea
> ) ;

No. Use "decode" to convert text to bytea, and "encode" to convert bytea
to text.

=> CREATE TABLE tb (b bytea);
CREATE TABLE
richardh=> INSERT INTO tb VALUES ( decode(E'\\000\\001\\002','escape') );
INSERT 0 1
richardh=> SELECT encode(b,'escape') FROM tb;
encode
--------------
\000\x01\x02
(1 row)

richardh=> SELECT encode(b,'hex') FROM tb;
encode
--------
000102
(1 row)

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message marcelo Cortez 2007-01-24 15:37:44 Re: how to read bytea field
Previous Message marcelo Cortez 2007-01-24 15:15:23 Re: how to read bytea field