Skip site navigation (1) Skip section navigation (2)

Re: Reading bytea field

From: Volkan YAZICI <volkan(dot)yazici(at)gmail(dot)com>
To: Jochen Kokemüller <jochen(at)kokemueller(dot)de>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Reading bytea field
Date: 2005-10-21 23:30:02
Message-ID: 7104a7370510211630s294123f6te3465b593c5e32a9@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-interfacespgsql-sql
Hi,

On 10/21/05, Jochen Kokemüller <jochen(at)kokemueller(dot)de> wrote:
> I read that it is better to use PQexecParams instead of PQescape. In the
> bytea field is then the picture with every Byte escaped. So the first
> few bytes look like this:
>
>  \377\330\377\340\000\020JFIF ...
>
> I wouldn't bother if i knew how to unescape this sequence. I supposed
> that this is more or less an internal representation, but when i try to
> retrieve the data. i get it like this.

If you'd use PQexecParams() for SELECT query with resultType = 1, you
shouldn't have any problem. Take a look at the examples in the
attachment.

Attachment: send.c
Description: text/x-csrc (1.3 KB)
Attachment: recv.c
Description: text/x-csrc (958 bytes)

In response to

pgsql-interfaces by date

Next:From: Louis CastoriaDate: 2005-10-25 17:04:33
Subject: libpq status question
Previous:From: Stefan T. PetersDate: 2005-10-21 20:28:11
Subject: Re: libpq won't connect when client is built with MinGW

pgsql-sql by date

Next:From: Tom LaneDate: 2005-10-22 03:23:48
Subject: Re: Blank-padding (was: Oracle buys Innobase)
Previous:From: Dean Gibson (DB Administrator)Date: 2005-10-21 23:28:48
Subject: Blank-padding (was: Oracle buys Innobase)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group