반응형
/********************************************************************************************
-- Title : [10g] 함수(Stored Function) 샘플
-- Reference : radiocom.kunsan.ac.kr
-- Key word : 함수 function stored function
********************************************************************************************/
-- 함수 샘플-1
create function scott.fn_get_salary return number
is
ret number;
begin
select sum(sal) into ret from emp;
return(ret);
end fn_get_salary;
-- Title : [10g] 함수(Stored Function) 샘플
-- Reference : radiocom.kunsan.ac.kr
-- Key word : 함수 function stored function
********************************************************************************************/
-- 함수 샘플-1
create function scott.fn_get_salary return number
is
ret number;
begin
select sum(sal) into ret from emp;
return(ret);
end fn_get_salary;
-- 함수 실행
select scott.fn_get_salary from dual;
-- 함수 샘플-2
create or replace function scott.fn_tax
( v_value in number
)
return number
is
begin
return (v_value*0.07);
end fn_tax;
-- 함수 실행
select scott.fn_tax(10) "val" from dual;
select sal, scott.fn_tax(sal)
from scott.emp;
update scott.emp
set sal = scott.fn_tax(sal)
where empno = 7934;
rollback;
반응형