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!

No data found in for loop cursor

oracle.beginnerMay 19 2017 — edited May 19 2017

Hi,

I want to handle NO Data found in for loop cursor. I am unable to print No data found in exception.

Could you please correct me where i am wrong?

declare

cursor c1 (l_id in number) then

select emp_name , salary from emp where emp_id=l_id;

Begin

for rec_c2 in c1(p_id) loop

dbms_output.put_line (rec_c2.emp_name || rec_c2.salary);

end loop;

exception

when no_data_found then

     dbms_output.put_line ('no data found');when others then

dbms_output.put_line (substr(SQLERRM,100));

end;

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 16 2017
Added on May 19 2017
9 comments
19,909 views