Oracle存储过程包含三部分:过程声明,执行过程部分,存储过程异常。

Oracle存储过程可以有无参数存储过程和带参数存储过程。 


一、无参程序过程语法


create or replace procedure NoParPro
as  ;
begin
;
exception     //存储过程异常
    ;
end;


 二、带参存储过程实例
create or replace procedure queryempname(sfindno emp.empno%type) as
 sName emp.ename%type;
sjob emp.job%type;
 begin
       ....
exception
          ....
end;

三、 带参数存储过程含赋值方式
create or replace procedure runbyparmeters  (isal in emp.sal%type, 
                            sname out varchar,sjob in out varchar)
as icount number;
begin
select count(*) into icount from emp where sal>isal and job=sjob;
if icount=1 then
 ....
else
 ....
end if;
exception
when too_many_rows then
DBMS_OUTPUT.PUT_LINE('返回值多于1行');
when others then
DBMS_OUTPUT.PUT_LINE('在RUNBYPARMETERS过程中出错!');
end;