Subject | Re: Cursor FETCH in PSQL and ROW_COUNT/'fetch past last record' error |
---|---|
Author | Dmitry Yemanov |
Post date | 2017-03-29T06:01:29Z |
28.03.2017 10:06, Martijn Tonies wrote:
condition is not an error (as per SQL spec). After that, you may fetch
prior and get the last record back. Moving cursor from EOF further can
be theoretically processed in two ways: (1) silent no-op (cursor remains
its position at EOF) and (2) raise an error. The former is somewhat
error prone (can lead to infinite loops, for example), perhaps this is
the reason why the engine raises an error instead. This is the logic
existing since InterBase for DSQL cursors, and it was applied to PSQL
cursors for consistency.
Dmitry
>Yes. Moving cursor from "last" to EOF is perfectly valid, "no data"
> So the first 'fetch' operation on a position that's invalid returns
> "rowcount=0",
> any additional fetch (which includes a move) returns an exception?
condition is not an error (as per SQL spec). After that, you may fetch
prior and get the last record back. Moving cursor from EOF further can
be theoretically processed in two ways: (1) silent no-op (cursor remains
its position at EOF) and (2) raise an error. The former is somewhat
error prone (can lead to infinite loops, for example), perhaps this is
the reason why the engine raises an error instead. This is the logic
existing since InterBase for DSQL cursors, and it was applied to PSQL
cursors for consistency.
Dmitry