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!

PL SQL ( NO_DATA_FOUND exception)

843389Feb 28 2011 — edited Feb 28 2011
I have the following chunk of code, which could return no rows, one row or many rows. When it
returns one or many rows the DBMS_OUTPUT.PUT_LINE prints out my values.

When no data is found 'Hello' is not printed?

1) Can somebody explain to me why this is happening?

2) Suggest a way I can change the code to make the exception print when no data is found?


SET SERVEROUTPUT ON;
BEGIN
FOR prec IN ( select * from xxx.part_maint where drop_partition = 'Y' )
LOOP
DBMS_OUTPUT.PUT_LINE (prec.SCHEMA_NAME || ' ' || prec.OBJECT_NAME);
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE ('hello');
END;
This post has been answered by Starlight Rider on Feb 28 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 28 2011
Added on Feb 28 2011
7 comments
112,593 views