dbTalk Databases Forums  

Re: how to get array-values using libpq?

comp.databases.postgresql comp.databases.postgresql


Discuss Re: how to get array-values using libpq? in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: how to get array-values using libpq? - 11-10-2006 , 03:44 AM






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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.