On Mon, 28 Aug 2000, Paula Greve wrote:
> Hi!
>
> Sorry for the very trivial and probably obvious question -- but I have
> looked all over the documentation and have been unable to find a discussion
> on this.
>
> When do I want to declare and use a cursor -- and why?
You want to use a cursor when you have a query that (potentially) returns a
large number of rows, so many, that it might exhaust memory if returned all at
once.
The cursor allows you to submit the query and then retrieve one or more of the
result rows/tuples at a time, which keeps memory usage low. You can move
forward and backward in the results to retrieve the same rows many times if you
need to without having to query again.
A cursor is also useful if you want to return information in pages at a time
for some application. You can move forward by x-per-page * pagenumber, to
retrieve the page wanted from the results. You have to include a SORT BY
in the query that is used to create the cursor to get pages in a meaningful
order.
Hope this helps a little. I might be able to come up with some examples if you
can't find any.
--
-------- Robert B. Easter reaster@comptechnews.com ---------
- CompTechNews Message Board http://www.comptechnews.com/ -
- CompTechServ Tech Services http://www.comptechserv.com/ -
---------- http://www.comptechnews.com/~reaster/ ------------