Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to test last row of cursor

Status
Not open for further replies.

BenjaminLim

IS-IT--Management
May 24, 2000
73
GB
How do I know within a cursor the last record selected so that I can use to determine a cause of action.

Please advice. Thanks.
 
Save the values of the record into a variable (possibly a declared record). That way, when you exit the cursor, the last values saved will persist.
 
Thanks.

I think but question was not very clear.

Need to know the last row so that if last row then output certain values else output another set of value.

Please advice.
 
In any case the record is the last if you can not fetch the next.
So you have to save your previous record somewhere else and delay your processing (do it on the next fetch when it's clear that your previous record is the last one)
 

For me, it's a two-step process:

1. Make a select count outside the cursor.
select count(*) into v_reccnt
from table1;


2. Inside your cursor, compare if the %ROWCOUNT is equal to the count you previously made, like,

IF cur1%rowcount = v_reccnt THEN
...display 1
ELSE
...display 2
END IF;


Not quite good though.




 
Rcurva, in this case you need to set the transaction to be read only for the sake of data consistency. Of course this requires aditional resources.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top