Re: How to retrieve values of 'array' field using C library (libpq)

From: Dmitriy Igrishin <dmitigr(at)gmail(dot)com>
To: Anton Maksimenkov <anton200(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to retrieve values of 'array' field using C library (libpq)
Date: 2011-02-09 11:53:37
Message-ID: AANLkTi=Q_kidcxB5iG3KiTrzurtrzqG=NC1_desQUz8N@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hey Anton,

2011/2/9 Anton Maksimenkov <anton200(at)gmail(dot)com>

> 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)?
>
Not in libpq. Probably, in libpqtypes.

> --
> antonvm
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

--
// Dmitriy.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dimitri Fontaine 2011-02-09 12:25:29 Re: créer une DLL pour Postgresql 9 avec visual C++ [2008]
Previous Message michel wildcat 2011-02-09 11:40:13 créer une DLL pour Postgresql 9 avec visual C++ [2008]