From: | Anton Maksimenkov <anton200(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | How to retrieve values of 'array' field using C library (libpq) |
Date: | 2011-02-09 08:14:49 |
Message-ID: | AANLkTikyNkMLpQMcYnqmrWcV32SZfCNVpdyD_aM5DKOo@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi.
I use libpq in my program. And I can retrieve int and symbolic fields
as simple as
int unameFN, moneyFN...
char *unamePTR, *moneyPTR...
unameFN = PQfnumber(res, "uname");
moneyFN = PQfnumber(res, "money");
unamePTR = PQgetvalue(res, 0, unameFN);
moneyPTR = PQgetvalue(res, 0, moneyFN);
themoney = ntohl(*((uint32_t *) moneyPTR));
printf("user->[uname:%s money:%d]", unamePTR, themoney);
Then I tried to use array type and no success:
int arFN...
char *arPTR...
arN = PQfnumber(res, "woo");
arPTR = PQgetvalue(res, 0, arFN);
printf("user->[woo:%s]", arPTR);
I can convert it with array_to_string() and got it as some text.
My array is the array of integer values. So maybe there is some native
method to retrieve them (as in the 'themoney' example)?
--
antonvm
From | Date | Subject | |
---|---|---|---|
Next Message | Thom Brown | 2011-02-09 09:50:09 | Re: [HACKERS] Issues with generate_series using integer boundaries |
Previous Message | Ogden | 2011-02-09 07:14:05 | Re: PostgreSQL 9.0 Streaming Replication Configuration |