pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedMethods for stepping through results?
5+ messages / 4 participants
[nested] [flat]
* Methods for stepping through results?
@ 1999-02-16 03:20 Matthew Hagerty <matthew@venux.net>
1999-02-16 15:47 ` Re: [INTERFACES] Methods for stepping through results? Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 5+ messages in thread
From: Matthew Hagerty @ 1999-02-16 03:20 UTC (permalink / raw)
To: pgsql-interfaces
Greetings,
Is there any way to do the following:
1. Return a query in groups of x (i.e. 10 or 20) and progressively return
result groups of x. Just think of search engine navigation.
2. I have a client who wants to be able to select certain rows (tuples) of
a result and then "re-submit" the query and have only those rows selected
in the new results. For example, if a query returns 10 rows and rows
2,4,7,9 are checked, when re-submitted only rows 2,4,7,9 would be returned.
I know it is kind of stupid, but I have to please the customer :(
The interface I'm using is libpq, apache server, and Netscape/IE.
Thanks,
Matthew
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [INTERFACES] Methods for stepping through results?
1999-02-16 03:20 Methods for stepping through results? Matthew Hagerty <matthew@venux.net>
@ 1999-02-16 15:47 ` Tom Lane <tgl@sss.pgh.pa.us>
1999-02-16 20:13 ` Re: [INTERFACES] Methods for stepping through results? Peter T Mount <peter@retep.org.uk>
0 siblings, 1 reply; 5+ messages in thread
From: Tom Lane @ 1999-02-16 15:47 UTC (permalink / raw)
To: Matthew Hagerty <matthew@venux.net>; +Cc: pgsql-interfaces
Matthew Hagerty <matthew@venux.net> writes:
> Is there any way to do the following:
> 1. Return a query in groups of x (i.e. 10 or 20) and progressively return
> result groups of x. Just think of search engine navigation.
DECLARE CURSOR ... FETCH ...
There has been some talk of providing a facility for this inside libpq,
where it could be used for handling the results of an ordinary SELECT.
But it doesn't seem real high priority, given that you can use a cursor.
> 2. I have a client who wants to be able to select certain rows (tuples) of
> a result and then "re-submit" the query and have only those rows selected
> in the new results. For example, if a query returns 10 rows and rows
> 2,4,7,9 are checked, when re-submitted only rows 2,4,7,9 would be returned.
> I know it is kind of stupid, but I have to please the customer :(
Seems like something you should be handling inside your application.
Why would you "re-submit" the same query in the first place, if you
already have the results?
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [INTERFACES] Methods for stepping through results?
1999-02-16 03:20 Methods for stepping through results? Matthew Hagerty <matthew@venux.net>
1999-02-16 15:47 ` Re: [INTERFACES] Methods for stepping through results? Tom Lane <tgl@sss.pgh.pa.us>
@ 1999-02-16 20:13 ` Peter T Mount <peter@retep.org.uk>
0 siblings, 0 replies; 5+ messages in thread
From: Peter T Mount @ 1999-02-16 20:13 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Matthew Hagerty <matthew@venux.net>; pgsql-interfaces
On Tue, 16 Feb 1999, Tom Lane wrote:
> Matthew Hagerty <matthew@venux.net> writes:
> > Is there any way to do the following:
> > 1. Return a query in groups of x (i.e. 10 or 20) and progressively return
> > result groups of x. Just think of search engine navigation.
>
> DECLARE CURSOR ... FETCH ...
>
> There has been some talk of providing a facility for this inside libpq,
> where it could be used for handling the results of an ordinary SELECT.
> But it doesn't seem real high priority, given that you can use a cursor.
Part of the JDBC2 spec has the option of this sort of handling of
select's.
Peter
--
Peter T Mount peter@retep.org.uk
Main Homepage: http://www.retep.org.uk
PostgreSQL JDBC Faq: http://www.retep.org.uk/postgres
Java PDF Generator: http://www.retep.org.uk/pdf
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [INTERFACES] Methods for stepping through results?
@ 1999-02-16 17:33 Matthew Hagerty <matthew@venux.net>
0 siblings, 0 replies; 5+ messages in thread
From: Matthew Hagerty @ 1999-02-16 17:33 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-interfaces
At 10:47 AM 2/16/99 -0500, Tom Lane wrote:
>Matthew Hagerty <matthew@venux.net> writes:
>> Is there any way to do the following:
>> 1. Return a query in groups of x (i.e. 10 or 20) and progressively return
>> result groups of x. Just think of search engine navigation.
>
>DECLARE CURSOR ... FETCH ...
>
>There has been some talk of providing a facility for this inside libpq,
>where it could be used for handling the results of an ordinary SELECT.
>But it doesn't seem real high priority, given that you can use a cursor.
>
Just a quick question about cursors. Say you have a query that returns
1000 rows (tuples), if I use libpq and PQexec, I am under the impression
that the whole result set is returned in the PQrestult structure, Yes? So
more big queries mean more memory used for each user accessing the database?
Now how does a cursor differ? Does the backend still have to run the whole
query and store the results somewhere? Or does a cursor return only one
row (tuple) at a time, which means less memory usage, but more work for the
backend?
I'm really unclear on why and when I would use a cursor instead of just
stepping through the PQrestult set. Afterall you can specify a row (tuple)
in PQfetchrow. All the books I have on SQL only tell how to use cursors,
none tell why or how they make anything better.
>> 2. I have a client who wants to be able to select certain rows (tuples) of
>> a result and then "re-submit" the query and have only those rows selected
>> in the new results. For example, if a query returns 10 rows and rows
>> 2,4,7,9 are checked, when re-submitted only rows 2,4,7,9 would be returned.
>> I know it is kind of stupid, but I have to please the customer :(
>
>Seems like something you should be handling inside your application.
>Why would you "re-submit" the same query in the first place, if you
>already have the results?
>
I know, I was thinking the same thing, why would I re-submit? But the
client software is a browser and I'm not sure how I would do it.
Thanks,
Matthew
^ permalink raw reply [nested|flat] 5+ messages in thread
* RE: [INTERFACES] Methods for stepping through results?
@ 1999-02-17 00:58 Vince DiCiero <vdiciero@home.com>
0 siblings, 0 replies; 5+ messages in thread
From: Vince DiCiero @ 1999-02-17 00:58 UTC (permalink / raw)
To: pgsql-interfaces
On Tuesday, February 16, 1999 9:47 AM, Tom Lane [SMTP:tgl@sss.pgh.pa.us] wrote:
> Matthew Hagerty <matthew@venux.net> writes:
> > Is there any way to do the following:
> > 1. Return a query in groups of x (i.e. 10 or 20) and progressively return
> > result groups of x. Just think of search engine navigation.
>
> DECLARE CURSOR ... FETCH ...
>
>
> > 2. I have a client who wants to be able to select certain rows (tuples) of
> > a result and then "re-submit" the query and have only those rows selected
> > in the new results. For example, if a query returns 10 rows and rows
> > 2,4,7,9 are checked, when re-submitted only rows 2,4,7,9 would be returned.
> > I know it is kind of stupid, but I have to please the customer :(
>
> Seems like something you should be handling inside your application.
> Why would you "re-submit" the same query in the first place, if you
> already have the results?
>
I don't think he wants to resubmit the same query, what he wants is to perform
a secondary query on the results of the first.
Probably what you should do is create a temporary table with the results of the first
query "SELECT INTO ...."
Use the DECLARE CURSOR to scroll through the results of the 1st query.
Then for the 2nd query, perform the query on the temporary table.
If you realy do want to do it as stated above where the re-submitted query only
returns the selected items from the first query, then why don't you display the
results of the first query in a list, and delete the unwanted items instead of performing
a 2nd query ?
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~1999-02-17 00:58 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-02-16 03:20 Methods for stepping through results? Matthew Hagerty <matthew@venux.net>
1999-02-16 15:47 ` Tom Lane <tgl@sss.pgh.pa.us>
1999-02-16 20:13 ` Peter T Mount <peter@retep.org.uk>
1999-02-16 17:33 Re: [INTERFACES] Methods for stepping through results? Matthew Hagerty <matthew@venux.net>
1999-02-17 00:58 RE: [INTERFACES] Methods for stepping through results? Vince DiCiero <vdiciero@home.com>
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