How to call a function in store procedure Oracle PL/SQL

create or replace function final_sal(v_empno number)
return number
is
v_newsal number;
v_sal number;
v_comm number;
begin
select sal,comm into v_sal,v_comm
    from emp
      where empno=v_empno;
if v_comm is null then
v_newsal :=nvl(v_comm,2000);
V_newsal := (v_newsal+v_sal)*12;
return v_newsal;
else
v_newsal := (v_sal+v_comm)*12;
return v_newsal;
end if;
end final_sal;


create or replace procedure emp_details(v_empno number)
 is
 v_ename varchar2(20);
 v_job varchar2(20);
 v_mgr varchar2(20);
 v_sal number;
 begin
 select ename,job,mgr into v_ename,v_job,v_mgr
      from emp
        where empno=v_empno;
 v_sal := final_sal(v_empno);  -- here i call that function 
dbms_output.put_line('Emp Name:' || v_ename);
dbms_output.put_line('Emp Job :' || v_job);
dbms_output.put_line('Emp Mgr:' || v_mgr);
dbms_output.put_line('Emp Total Sal:' || v_sal);
end emp_details;

People who read this post also read :



2 comments:

There is a similar blog containing articles on fundas and concepts about database systems. A must read for every database professional - beginner or expert. Visit : http://crazy4db.blogspot.in

Sir is there real time project and session .. And class in Nagpur?

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More