Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 1289B9FB6A7 for ; Mon, 9 Oct 2006 12:30:17 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 46424-04 for ; Mon, 9 Oct 2006 12:30:11 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from nihrelayxway2.hub.nih.gov (mailfwd.nih.gov [128.231.90.107]) by postgresql.org (Postfix) with ESMTP id 296819FB6A4 for ; Mon, 9 Oct 2006 12:30:10 -0300 (ADT) Received: from pressa.nci.nih.gov ([137.187.209.230]) by nihrelayxway2.hub.nih.gov with ESMTP; 09 Oct 2006 11:30:07 -0400 X-IronPortListener: NIH_Relay X-SBRS: None X-IronPort-AV: i="4.09,284,1157342400"; d="scan'208"; a="201556379:sNHT14997224" From: Sean Davis Reply-To: sdavis2@mail.nih.gov Organization: NIH/NCI To: pgsql-interfaces@postgresql.org Subject: Re: Retrieve all the returned rows in one call Date: Mon, 9 Oct 2006 11:30:06 -0400 User-Agent: KMail/1.9.1 Cc: "Andreas Gidlund" References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200610091130.06335.sdavis2@mail.nih.gov> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200610/4 X-Sequence-Number: 6287 On Monday 09 October 2006 10:58, Andreas Gidlund wrote: > I am right now using the libpq interface and struggling with efficiently > retrieve the result from a query. > > Let's say I run a select statement with some where clauses and then > retrieve the result into a PGresult. I want to know if there is an > efficient way to retrieve all the rows at once? I am going to return a > char*** from my function, i.e. a two-dimensional array of char pointers. > I have seen the COPY sql command, but up to v8.1 i cannot use a select > statement with it, the only way to customize COPY is to choose which > columns to return, but still, the only option is to return the whole table. > Furthermore, when using PQgetCopyData I get the whole row at once, but I > still have to loop through all rows. > I have also seen in the PGresult structure that it has a member called > tuples, which is a two-dimensional array of the structure PGresAttValue. > This is a way to recieve all the data at once, but it is in a format which > is specific for PostgreSQL and I am developing a database interface > including other databases two, so I want to use a general structure > returned from the function, i.e. a char***. This means that I would have to > loop through the tuples array to convert into the char array structure, and > hence lose the whole meaning with recieving all the rows at once. > > So my question is if it is possible in any way to retrieve the result in > the form of char***? I think the answer is no. Sean