1、创建存储过程
SQL> create or replace procedure myproc(i_deptno number) is
2 v_dname varchar2(20);
3 begin
4 select dname into v_dname from dept where deptno = i_deptno;
5 dbms_output.put_line(v_dname);
6 end myproc;
7 /
说明:如果存储过程编译错误,可以用show errors 或者show errors procedure myproc查看错误
2、调用存储过程
方式一
SQL> declare
2 deptno number(2);
3 begin
4 deptno := 10;
5 myproc(deptno);
6 end;
7 /
说明:最普通的方式,可以有入参和出参
方式二
SQL> begin
2 myproc(10);
3 end;
4 /
说明:这种方式只能有入参,并且是常量
方式三
SQL> execute myproc(10)
说明:这种方式只能有入参,并且是常量,一旦写了begin 和 end就不能用execute