pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Retrieve all the returned rows in one call
2+ messages / 2 participants
[nested] [flat]

* Retrieve all the returned rows in one call
@ 2006-10-09 14:58  Andreas Gidlund <vaxis@hotmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Andreas Gidlund @ 2006-10-09 14:58 UTC (permalink / raw)
  To: pgsql-interfaces

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/




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Retrieve all the returned rows in one call
@ 2006-10-09 15:30  Sean Davis <sdavis2@mail.nih.gov>
  parent: Andreas Gidlund <vaxis@hotmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Sean Davis @ 2006-10-09 15:30 UTC (permalink / raw)
  To: pgsql-interfaces; +Cc: Andreas Gidlund <vaxis@hotmail.com>

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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2006-10-09 15:30 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-10-09 14:58 Retrieve all the returned rows in one call Andreas Gidlund <vaxis@hotmail.com>
2006-10-09 15:30 ` Sean Davis <sdavis2@mail.nih.gov>

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