Sascha Bohnenkamp <bohnenkamp (AT) mevisbreastcare (DOT) de> wrote:
Quote:
how to get array-values using libpq?
I found nothing about it in the documentation and no examples?! |
For PQexec(), write array literals as you would in psql.
If you intend to use PQexecParams() or PQexecPrepared(), set the
respective element of paramTypes[] to the OID of the array type and
use (e.g.) "{val1,val2,val3}" as entry in paramValues[].
When retrieving an array type, PQftype() and PGgetvalue() work the same,
i.e. they return the array type OID and the array in the form
"{elem1,elem2,elem3}".
This is when you use text format.
For binary format, you will want to use the functions in
<postgres>/include/server/utils/array.h
to construct or access an ArrayType.
I have never done that, but e.g. array_ref() should retrieve an element
of the array, etc. Experiment with it!
Yours,
Laurenz Albe