Re: how to read bytea field

Поиск
Список
Период
Сортировка
От marcelo Cortez
Тема Re: how to read bytea field
Дата
Msg-id 620339.22521.qm@web32103.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на Re: how to read bytea field  (Markus Schiltknecht <markus@bluegap.ch>)
Ответы Re: how to read bytea field  (Richard Huxton <dev@archonet.com>)
Список pgsql-general
folks


 my table

CREATE TABLE pblfield
(
  id_ integer NOT NULL,
  value_field bytea,
  name character varying(128),
  osset integer,
  length integer,
  version_ integer,
  inst_class_ character varying(128),
  CONSTRAINT pblfield_pkey PRIMARY KEY (id_)
)

 insert into pblfield( id_ , value_field ) values( 1 ,
encode(E'\\000\\001', 'escape') ) ;
 insert into pblfield( id_ , value_field ) values( 2 ,
encode(E'\\000\\002', 'escape') ) ;
 etc...

 now, i want to recover value_field in text form
some thing like..


  select id_ , decode(value_field) from pblfield ;

  WRONG WRONG ... decode has text parameter ...!!!!!

  Ok ,next try .

  select id_ , decode(value_field ::text ) from
pblfield.

  WRONG WRONG ... bytea not cast to string  ...!!!!!

  so, how do that ???


  I think solution is:

CREATE TABLE pblfield
(
  id_ integer NOT NULL,
  value_field text ,   /*!!!!  here text field */
  name character varying(128),
  osset integer,
  length integer,
  version_ integer,
  inst_class_ character varying(128),
  CONSTRAINT pblfield_pkey PRIMARY KEY (id_)
)

 insert into pblfield( id_ , value_field ) values( 1 ,
encode('\\000\\001', 'escape')::text  ) ;
 insert into pblfield( id_ , value_field ) values( 2 ,
encode(E'\\000\\002', 'escape') ::text  ) ;

  select id_ , value_field from  pblfield ;

  works  and
  select id_ , decode(value_field ,'escaped' )  from
pblfield ;

  works too!!!

  folks thanks for your time and responses.
  best regards

 Last cuestion , when bytea field ( type)   is usable?

 for storage to external files???










__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas


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

Предыдущее
От: Markus Schiltknecht
Дата:
Сообщение: Re: how to read bytea field
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: how to read bytea field