Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fetch TEXT column value from postgresql

Tags:

postgresql

I have a the following simple table in postgreSQL:

CREATE TABLE data ( id bigint NOT NULL, text_column text, );

The values of the text_column , as I see them in the phpPgAdmin web site, are numbers (long). As I read, postgreSQL keeps a pointer to the actual data. How can I fetch the actual string value of the text_column? Doing:

select text_column from data 

returns numbers...

Thanks

like image 951
Ben Bracha Avatar asked Aug 28 '12 08:08

Ben Bracha


1 Answers

Following helped us:

select convert_from(loread(lo_open(value::int, x'40000'::int), x'40000'::int),  'UTF8') from t_field;

where value is field, which contains TEXT, and t_field is obviously name of table.

like image 157
asm0dey Avatar answered Oct 20 '22 01:10

asm0dey