Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception handling in pl/sql

Tags:

oracle

plsql

I have a stored procedure

create or replace procedure Trial
    is 
Begin
---Block A--
EXCEPTION
when others then
insert into error_log values('error');
--Block A ends----
--Block B ----
----Block B ends---
end;

I want code in Block B to execute in all condition i.e if exception in Block A is raised or not.With the above code Block B executes only if exception is raised. How to do this. Please help.

like image 469
Niraj Choubey Avatar asked Jun 06 '11 12:06

Niraj Choubey


1 Answers

You can created nested blocks:

create or replace procedure Trial
    is 
Begin
  begin
    ---Block A--
  EXCEPTION
    when others then
      insert into error_log values('error');
  end;
  begin
    --Block B ----
  end;
end;
like image 114
Tony Andrews Avatar answered Sep 22 '22 02:09

Tony Andrews