Subject Re: [ib-support] Cursors?
Author Paul Schmidt
Gerhardus:

On 12 Oct 2001, at 10:56, Gerhardus Geldenhuis wrote:

> I have read the explanation in the Language Reference and the data
> definition guide of which bove explains what a cursor is but to me it
> is not very clear.
>
> "A cursor is a one-way pointer into the ordered set of rows retrieved
> by the select expression in the DECLARE CURSOR statement. It enables
> sequential access to retrieved rows in turn."
>
> What would be the typical application of a cursor. When is it a good
> idea to use and when not. I cant see the difference between a cursor
> and a select statement to me it appears as if they achieve the same
> goal.

Cursors get used all the time, it's a little like a screen cursor, it
points to where the data is. Most middleware hides the cursor it
uses internally. Effectively it works like this, if you use the API,
I will leave out the actual commands, because I don't have time to
look them up.

You declare a cursor
you execute the SQL using the cursor, as one of the function
arguements
You do a Fetch on the cursor
You use the data
You do another Fetch on the cursor
repeat until your done, or run out od data.

Unfortunately, Cursors tend to be uni-directional, in that you can
get the next value, but not the previous value. Bi-directional
middleware either bookmarks the values as they go by, or uses
multiple cursors to do it's work, or re-executes the SQL.

HTH

Paul









Paul Schmidt,
Tricat Technologies
Email: paul@...
Website: www.tricattechnologies.com