Search Postgresql Archives

Re: how to read bytea field

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

 



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 



[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