ed fn_sum2
create or replace function fn_sum2
(v_sum1 in number,
v_sum2 in number)
return number
is
v_sum number;
begin
v_sum :=v_sum1 + v_sum2;
return v_sum;
end;
/
@fn_sum2
variable sum number;
execute :sum :=fn_sum2(10,20)
print sum;
select fn_sum2(10,20) from dual;
--------------------------------------
ed sum_dept;
create or replace function sum_dept
(v_deptno in dept.deptno%type)
return number
is
v_sum number;
begin
select sum(sal) into v_sum from emp
where deptno=v_deptno;
return v_sum;
end;
/
@sum_dept;
select sum_dept(10) from dual;
------------------------------------------
ed emp_sal
create or replace function emp_sal
(v_empno in emp.empno%type)
return number
is
v_empsal number;
v_sal number;
begin
select sal into v_empsal from emp
where empno=v_empno;
v_sal:=v_empsal*1.5;
return v_sal;
end;
/
@emp_sal;
select emp_sal(7900) from dual;
------------------------------------------
ed ssss;
create or replace function ssss
(v_ename in emp.ename%type)
return varchar2
is
v_dname dept.dname%type;
begin
select d.dname into v_dname from (select deptno from emp where ename=UPPER(v_ename)) e,dept d
where d.deptno=e.deptno;
return v_dname;
end;
/
@ssss
select ssss('SMITH') from dual;
'개발 > sql' 카테고리의 다른 글
oracle 중간점검 (0) | 2015.10.07 |
---|---|
oracle sql 서브쿼리,function,no_data_found,too_many_rows,others (0) | 2015.10.07 |
oracle sql cursor update,delete, 무결성 제약조건 (0) | 2015.10.06 |
oracle sql 암시적 커서,명시적 커서,loop (0) | 2015.10.05 |
oracle sql (0) | 2015.10.05 |
댓글