Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: DBMS_SQL.CURSOR: How to check if Last Row has been reached ?
l_retVal will be 0 when there's no more rows to fetch, which
means that previous row was the last in data set. This is not
really helpful in your case since you can't find out if the row
is last in the data set before you process it and attempt to fetch
next row, but that's the way cursors in Oracle work. Possible
workaround is to prefetch next row into another set of variables
and check if it was successful - if it wasn't, then you reached
last row. This way you will implement something like a sliding
window of two rows into the cursor, current row and next row,
so that you can detect end of data set before processing current
row, and you will need to copy fetched next row values into
current row values before fetching next next row.
Corrections and additions welcome.
-- Vladimir Zakharychev (bob@dpsp-yes.com) http://www.dpsp-yes.com Dynamic PSP(tm) - the first true RAD toolkit for Oracle-based internet applications. All opinions are mine and do not necessarily go in line with those of my employer. "Filiz Duman" <filiz.duman_at_bt.com> wrote in message news:amv21a$229$1_at_pheidippides.axion.bt.co.uk...Received on Fri Sep 27 2002 - 06:48:45 CDT
> I have following Cursor:
>
> l_cursor := DBMS_SQL.OPEN_CURSOR;
> DBMS_SQL.PARSE(l_cursor, l_sqlStatement, DBMS_SQL.native);
> l_retVal := DBMS_SQL.EXECUTE(l_cursor);
>
> loop
> l_retVal := DBMS_SQL.FETCH_ROWS(l_cursor);
>
> /* do different things */
>
> end loop
>
> Within the loop how can I check:
>
> if (last row)
> then....
>
> Many thanks in advance.
>
>
>
>
![]() |
![]() |