======== 有返回值的函数 =========
– 函数案例
– 输入雇员的姓名,返回该雇员的年薪
create or replace function sp_fun1(spName varchar2) return number is yearSal number(7, 2) ;
begin
– 执行部分
select sal*12 + nvl(comm, 0)*12 into yearSal from emp where ename = spName;
return yearSal;
end;
====== 在sql developer中调用有返回值的函数 =========
declare
income number;
begin
income := sp_fun1(‘songyl’);
dbms_output.put_line(‘年薪:’ || income);
end;