I'm converting an ingres C program to Oracle Pro*C.
I create and open a cursor to do a SELECT (not a SELECT FOR UPDATE).
The existing program does (roughly)
EXEC SQL DECLARE N CURSOR for SELECT...
EXEC SQL OPEN N
EXEC SQL FETCH N INTO :new
while (sqlca.sqlcode != 100) {
// process the contents of :new
EXEC SQL FETCH N INTO :new
}
EXEC SQL CLOSE N;
When I reach the last line returned by the select statement, I get an error, ORA-01002: fetch out of sequence.
I don't want to put my cleanup code in my error handler; I would rather that the loop exit cleanly.