> begin;
> declare cursor c ...;
> fetch 1 from c; -- returns tuple 1
> begin;
> fetch 1 from c; -- returns tuple 2
> rollback;
> fetch 1 from c; -- returns tuple 1 again
>
> This is mightly ugly but I think it's the most usable of the options
> seen so far.
Imho most usabel would be to handle the cursor like a hold corsor.
begin; declare cursor c ...; fetch 1 from c; -- returns tuple 1 begin; fetch 1 from c; -- returns
tuple2 rollback; fetch 1 from c; -- returns tuple 3
For me the reason is, that most likely you are not going to rollback
because the fetch did not work or returned something you don't like.
Most likely some consequent action did not work out, and the next step
will be to correct (or ignore) the problem. You can do that without an
extra fetch, because you still have the values in host variables.
resetting to "tuple 1" imho opens the door for endless loops.
Andreas