From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
---|---|
To: | Daniel <danwgrace(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Examples of using PQexecParams |
Date: | 2009-12-04 21:05:13 |
Message-ID: | b42b73150912041305y3561aa21nb8494a4f8db96ff5@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, Dec 4, 2009 at 1:47 PM, Daniel <danwgrace(at)gmail(dot)com> wrote:
> I was looking for examples of using PQexecParams but all I found was
> this: http://sepp.oetiker.ch/postgresql-8.2.3-ds/libpq-example.html
>
> /* Convert integer value "2" to network byte order */
> binaryIntVal = htonl((uint32_t) 2);
> /* Set up parameter arrays for PQexecParams */
> paramValues[0] = (char *) &binaryIntVal;
> paramLengths[0] = sizeof(binaryIntVal);
> paramFormats[0] = 1; /* binary */
check out libpqtypes (http://libpqtypes.esilo.com) It does all the
binary stuff for you (which you don't need to to with PQexecParams).
with libpqtypes, you can do stuff like:
res = PQexecf(conn, "insert into foo values (%int4, %text)", 2, "test");
note: libpqtypes requires a patched libpq for client versions < 8.4
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Denes Daniel | 2009-12-05 01:23:13 | Re: Array comparison & prefix search |
Previous Message | John R Pierce | 2009-12-04 19:50:03 | Re: Examples of using PQexecParams |