Submitted by: ravenkumar
/* simple example for calling procedure from a another procedure with system and user define exception */
set serveroutput on
create or replace procedure proc1 is -- calling procedure from emp_id.
v_time timestamp; -- time stamp for calling procedure.
begin
select systimestamp -- selecting time stamp from dual table.
into v_time from dual;
dbms_output.put_line(v_time);
update emp -- update employees.
set salary = 25000
where employee_id = 100;
end proc1;
/
create or replace procedure emp_id -- mail procedure.
(emp in emp.employee_id%type,
sal out emp.salary%type) is
excep exception;
excep1 exception;
v_time timestamp; -- time stamp for mail procedure.
begin
select systimestamp -- selecting time stamp from dual table.
into v_time from dual;
dbms_output.put_line(v_time);
select salary -- fetch the salary for analyze.
into sal
from emp
where employee_id = emp;
/* check conditions */
if sal = 24000 then proc1;
elsif sal >= 25000 then raise excep;
else raise excep1; -- raise exception.
end if;
exception
when no_data_found -- system exception.
then dbms_output.put_line('no record found');
when excep -- user define exception.
then dbms_output.put_line('already have the salary');
when excep1 -- user define exception.
then dbms_output.put_line('not in employee_id in proc1');
end emp_id;
/
show errors;
/
variable sa number
execute emp_id (100, :sa)
show errors;
Above answer was rated as good by the following members:
kperumal75