Search Postgresql Archives

Re: how to read bytea field

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux