完成业务功能处理,不能返回值
存储过程的参数类型:
in 输入参数–向存储过程内传递值out 输出参数–得到存储过程里的值例子:
①:
create or replace procedure pro_countemp2(dno in emp.deptno%type, empcount out number) is begin declare v_count number(3,0); begin select count(empno) into v_count from emp where deptno=dno; empcount:=v_count; end; end;调用存储过程:
declare v_count2 number(3,0):=0; begin pro_countemp2(10,v_count2); --输出v_count的值 dbms_output.put_line(v_count2); end;②: 声明函数
create or replace function fun_countemp(dno emp.deptno%type) return number is begin declare v_count number(3,0):=0; begin select count(empno) into v_count from emp where deptno=dno; return v_count; end; end;调用函数
declare v_empCount number(3,0):=0; begin --接收函数的返回值 v_empCount:=fun_countemp(10); dbms_output.put_line(v_empCount); end;