I have a hata
table with the following data;
| sube | error_message |
--------------------------
| 5 | sdadasdasdas |
| 5 | sadadsadasda |
| 7 | sadsadaslkgk |
| 7 | aasdasdkfsjdj |
| 9 | sjsjfjssdf |
I have following cursor;
current_sube NUMBER := 0;
CURSOR c_error
IS
select sube, error_message
from hata
order by sube;
I am fetching this like
OPEN c_error;
LOOP
BEGIN
FETCH c_error INTO hata_mail;
----
IF hata_mail.sube = current_sube
add row to array;
ELSE
do my job;
empty array;
current_sube = hata_mail.sube;
----
END;
END LOOP;
CLOSE c_error;
My question starts from FETCH
statement.
For each row that is fetched, if sube
column and current_sube
is same then add row to an array, else do my specific job and empty array.
This logic works until last row because in last row, there is an unempty array and I couldn't my specific job.
Is there any suggestion to achieve this?
Set current_sube
variable before fetch
statement and check the last row using cursor%rowcount
.