Thread: Binary data in bytea field

Binary data in bytea field

From
Iklódi Lajos
Date:
I have a table with field of tyte bytea. I'm reading this table with C,
libpq.
The result is a string, with octal groups, like '\200'.
Is it possible to get data as it is, every byte in one byte?
Thanks




Re: Binary data in bytea field

From
Joe Conway
Date:
Iklódi Lajos wrote:
> I have a table with field of tyte bytea. I'm reading this table with C,
> libpq.
> The result is a string, with octal groups, like '\200'.
> Is it possible to get data as it is, every byte in one byte?
> Thanks
> 

Sure -- just use a binary cursor.

HTH,

Joe





Re: Binary data in bytea field

From
Iklódi Lajos
Date:
> Iklódi Lajos wrote:
> > I have a table with field of tyte bytea. I'm reading this table with C,
> > libpq.
> > The result is a string, with octal groups, like '\200'.
> > Is it possible to get data as it is, every byte in one byte?
> > Thanks
> >
>
> Sure -- just use a binary cursor.
>
> HTH,
>
> Joe

Thanks, really it is in docs.
How can I make binary updates?

Lajos




Re: Binary data in bytea field

From
Joe Conway
Date:
Iklódi Lajos wrote:
>>Iklódi Lajos wrote:
>>
>>>I have a table with field of tyte bytea. I'm reading this table with C,
>>>libpq.
>>>The result is a string, with octal groups, like '\200'.
>>>Is it possible to get data as it is, every byte in one byte?
>>>Thanks
>>>
>>
>>Sure -- just use a binary cursor.
>>
>>HTH,
>>
>>Joe
> 
> 
> Thanks, really it is in docs.
> How can I make binary updates?
> 
> Lajos
> 

See:
http://www.us.postgresql.org/users-lounge/docs/7.2/postgres/libpq-exec.html
section 1.3.3 "Escaping binary strings for inclusion in SQL queries".

Joe