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

Re: [DEFAULT] Daily digest v1.4551 (20 messages)

From: Jerry LeVan <jerry(dot)levan(at)eku(dot)edu>
To: daniel(at)manitou-mail(dot)org
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: [DEFAULT] Daily digest v1.4551 (20 messages)
Date: 2004-07-28 19:45:10
Message-ID: A2AF1F4F-E0CE-11D8-BC31-000393779D9C@eku.edu (view raw or flat)
Thread:
Lists: pgsql-general
Thank you Daniel,

Is it the case that "insert" could be used in a similiar
fashion to load the bytea field?

Jerry

On Jul 28, 2004, at 3:07 PM,Daniel Verite wrote:

>
> Date: Wed, 28 Jul 2004 16:45:10 +0200
> From: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
> To: "Postgres General" <pgsql-general(at)postgresql(dot)org>
> Subject: Re: Loading/Retrieving bytea fields?
> Message-ID: <20040728164529(dot)5143560(at)uruguay(dot)brainstorm(dot)fr>
>
> 	 Jerry LeVan writes
>
>> Has anyone found some C code that shows how to load/extract data from 
>> a
>> bytea column?
>
> This works for me:
>
> int size;
> const char* contents;
> PGresult* res;
> res = PQexecParams(pgconn,
>         "SELECT contents FROM tblob WHERE pkey=value",
>         0, NULL,NULL,NULL,NULL,   /* no input parameters */
>         1  /* output in binary format */ );
>
> if (res && PQresultStatus(res)==PGRES_TUPLES_OK) {
>   size = PQgetlength(res, 0, 0);
>   contents = PQgetvalue(res, 0, 0);	/* binary representation */
> }
>
> I believe that you may also use the plain PQexec instead of 
> PQexecParams,
> but then you would have to call PQunescapeBytea() on the bytea column 
> in the
> results, so it's likely to be less efficient. I haven't tried that, 
> though.
>


Responses

pgsql-general by date

Next:From: Geoff CaplanDate: 2004-07-28 20:08:56
Subject: Re: php -postgresql
Previous:From: Martin MarquesDate: 2004-07-28 19:15:08
Subject: Re: php -postgresql

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