Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Correct way of capturing exception when no rows fetched

Orcl ApexFeb 26 2022

Hi All,
Could you guide me on the right way of raising the no_data_found exception if the cursor doesn't return a row, close the cursor, and exit from the loop?

OPEN cursor_name;
LOOP
FETCH cursor_name INTO cursor_rt;
IF cursor_name%NOTFOUND THEN CLOSE cursor_name;
EXIT;
END IF;
RAISE NO_DATA_FOUND
_logic_

EXIT;       \_exit\_  
EXIT WHEN   \_condition\_  

END LOOP;

CLOSE cursor_name;

This post has been answered by Paulzip on Feb 27 2022
Jump to Answer
Comments
Post Details
Added on Feb 26 2022
4 comments
2,607 views