From: Brett Schwarz <brett_schwarz@yahoo.com>
To: Akbar Mokhtarani <akbarm@slac.stanford.edu>
To: PostgreSQL-interfaces <pgsql-interfaces@postgresql.org>
Subject: Re: Array elements (urgent help needed)
Date: Sun, 3 Oct 2004 20:45:12 -0700 (PDT)
Message-ID: <20041004034512.387.qmail@web40626.mail.yahoo.com> (raw)
In-Reply-To: <Pine.LNX.4.58.0410031950350.32241@noric03.slac.stanford.edu>
I really haven't work with arrays that much at the C
level, but I thought that the result from PQgetvalue
was just a char string. If it is an array, I thought
that the string would look like: {elem1, elem2,
elem3, ...}.
I don't think there are any helper functions for this,
so you need to manually walk that char string to peel
out the elements...at least as far as I am aware. You
might want to look at the how the operators for arrays
access the elements, e.g. the <> operator for arrays.
Again, I'm not expert, but this is what I had thought
is the case. I hope I understood your question.
HTH,
--brett
--- Akbar Mokhtarani <akbarm@slac.stanford.edu> wrote:
> I am desparate to find a way to access array
> elements from my c/c++
> program. I have stored int and double data as arrays
> in my tables and need
> to retrieve them from the database. I use a binary
> cursor to store the
> query results and PQgetvalue gives me a char*
> pointer to the storage area
> where the data is stored (this is according to the
> documentation). I have
> tried to understand the internal structure of the
> storage area, but it
> changes with data type. I suspect there is a more
> reliable/elegant way to
> get access to the elements. What is the correct way
> of doing this?
>
> Thanks in advance.
>
> Akbar Mokhtarani
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: brett_schwarz@yahoo.com, akbarm@slac.stanford.edu
Subject: Re: Array elements (urgent help needed)
In-Reply-To: <20041004034512.387.qmail@web40626.mail.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox