Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 63E1F9FA2A6; Tue, 10 Oct 2006 12:28:09 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 47246-05; Tue, 10 Oct 2006 15:28:04 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- X-Greylist: from auto-whitelisted by SQLgrey- Received: from mmp2.nems.noaa.gov (mmp2.nems.noaa.gov [140.90.121.157]) by postgresql.org (Postfix) with ESMTP id A437E9FA220; Tue, 10 Oct 2006 12:28:04 -0300 (ADT) Received: from [10.1.10.144] (opps-gw.nohrsc.nws.gov [192.46.108.142]) by mmp2.nems.noaa.gov (iPlanet Messaging Server 5.2 HotFix 2.01 (built Aug 26 2004)) with ESMTPSA id <0J6X00IX4EYQXZ@mmp2.nems.noaa.gov>; Tue, 10 Oct 2006 11:28:03 -0400 (EDT) Date: Tue, 10 Oct 2006 10:28:02 -0500 From: andy rost Subject: Re: [pgsql-interfaces] Daily digest v1.1236 (2 messages) In-reply-to: <20061010152010.2A7FF8B393F@mx2.hub.org> To: pgsql-interfaces-owner@postgresql.org Cc: pgsql-interfaces@postgresql.org Message-id: <452BBC02.7090606@noaa.gov> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 8BIT User-Agent: Thunderbird 1.5.0.2 (X11/20060420) References: <20061010152010.2A7FF8B393F@mx2.hub.org> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200610/5 X-Sequence-Number: 6288 pgsql-interfaces-owner@postgresql.org wrote: > Message Digest > Volume 1 : Issue 1236 : "text" Format > > Messages in this Issue: > Retrieve all the returned rows in one call > Re: Retrieve all the returned rows in one call > > ---------------------------------------------------------------------- > > Date: Mon, 09 Oct 2006 16:58:05 +0200 > From: "Andreas Gidlund" > To: pgsql-interfaces@postgresql.org > Subject: Retrieve all the returned rows in one call > Message-ID: > > 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***? > > _________________________________________________________________ > Gör karriär! http://monster.msn.se/ > > > ------------------------------ > > Date: Mon, 9 Oct 2006 11:30:06 -0400 > From: Sean Davis > To: pgsql-interfaces@postgresql.org > Cc: "Andreas Gidlund" > Subject: Re: Retrieve all the returned rows in one call > Message-ID: <200610091130.06335.sdavis2@mail.nih.gov> > > 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 > > ------------------------------ > > End of [pgsql-interfaces] Daily digest v1.1236 (2 messages) > ********** We had a similar issue. Don't know if this will work for you but you may want to look into FETCH ALL -- -------------------------------------------------------------------------------- Andrew Rost National Operational Hydrologic Remote Sensing Center (NOHRSC) National Weather Service, NOAA 1735 Lake Dr. West, Chanhassen, MN 55317-8582 Voice: (952)361-6610 x 234 Fax: (952)361-6634 andy.rost@noaa.gov http://www.nohrsc.noaa.gov --------------------------------------------------------------------------------