标签:bms put 参数 ber font number int pre span
1、必须返回一个值
2、只能在表达式调用
SQL> create or replace function fun1 2 return number 3 is 4 v_sum_sal emp.sal%type; 5 6 begin 7 select sum(sal) into v_sum_sal from emp where deptno=10; 8 return v_sum_sal; 9 end; 10 / Function created SQL> SQL> declare 4 v_sumsal emp.sal%type; 5 6 begin 7 8 v_sumsal := fun1; 9 dbms_output.put_line(v_sumsal); 10 11 end;
带有参数的函数:
IN:
SQL> create or replace function fun1 2 ( v_deptno in number) 3 return number 4 is 5 v_sum_sal emp.sal%type; 6 7 begin 8 select sum(sal) into v_sum_sal from emp where deptno=v_deptno; 9 return v_sum_sal; 10 end;
SQL> declare 2 v_sumsal emp.sal%type; 3 4 begin 5 6 v_sumsal := fun1(10); 7 dbms_output.put_line(v_sumsal); 8 9 end;
OUT:
SQL> create or replace function fun2 2 3 (v_empno number , v_ename out varchar2,v_sal out number) 4 5 return number 6 7 is 8 9 begin 10 11 select ename,sal into v_ename,v_sal from emp where empno=v_empno; 12 return v_sal; 13 end; 14 / Function created SQL> declare 2 3 v_salary emp.sal%type; 4 v_ename emp.ename%type; 5 v_sal emp.sal%type; 6 7 begin 8 v_salary := fun2(7369,v_ename,v_sal); 9 dbms_output.put_line (‘Salary is: ‘||v_salary); 10 11 end;
标签:bms put 参数 ber font number int pre span
原文地址:http://www.cnblogs.com/tomatoes-/p/6104508.html