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!

Question on Exception handling

Mark82Oct 23 2025

DB version: 19c

I am bit of a basic user on PL/SQL.

I wrote a loop like below.

My requirement
If any of the commands (dbms_aqadm.<procedures> shown below) within the loop fails, I want that error/errors to be printed (raised) but I still want the loop to continue iterating (don't exit) until all the records in the cursor is iterated through.

begin
for rec in (select owner,name, queue_table from dba_queues where owner = 'QSCHEMA03') 
loop
	begin
  	dbms_aqadm.stop_queue(queue_name => rec.owner||'.'||rec.name);
  	dbms_aqadm.drop_queue(queue_name => rec.owner||'.'||rec.name);
  	dbms_aqadm.drop_queue_table(queue_table => rec.owner||'.'||rec.queue_table, force=>true);
  	
  	exception when others then
       	raise;
	end;
end loop;
end;
/

Can the exception block

exception when others then
       raise;

achieve it ? This is what I am currently using in my loop.

I know

exception when others then
       null;

can do it. But, this will mask the errors.

I want the errors to be printed (raised) but loop should continue until all the records in the cursor is iterated.

This post has been answered by Solomon Yakobson on Oct 23 2025
Jump to Answer
Comments
Post Details
Added on Oct 23 2025
4 comments
99 views