oracle的存储过程怎么写?

解决方案 »

  1.   

    太依赖csdn了,网上一搜好多的资料!
      

  2.   

    CREATE OR REPLACE PROCEDURE --保留字,创建存储过程的命令
    update_commission( --存储过程名
      v_dept IN NUMBER, --输入参数
      v_pervent IN NUMBER DEFAULT 10 --输入参数,如果没有传该参数,缺省值是10
    ) IS --保留字,必须--以上为声明部分,下面begin和end之间为真正的执行部分
    BEGIN --保留字,执行部分开始
       update emp  set comm = sal * v_percent  where deptno = v_dept; --普通SQL语句
    END; --保留字,执行部分结束
    /--可参考其它的资料 http://www.yesky.com/zhuanti/179/1887179.shtml
      

  3.   

    存储过程创建语法:
    create or replace procedure 存储过程名(param1 in type,param2 out type) as 变量1 类型(值范围);变量2 类型(值范围);Begin    Select count(*) into 变量1 from 表A where列名=param1;    If (判断条件) then       Select 列名 into 变量2 from 表A where列名=param1;       Dbms_output。Put_line(‘打印信息’);    Elsif (判断条件) then       Dbms_output。Put_line(‘打印信息’);    Else       Raise 异常名(NO_DATA_FOUND);    End if;Exception    When others then       Rollback;End;
      

  4.   

    创建存储过程:
    create or replace procedure test_ppp is
      c number;
    begin
      select count(1) into c from cat where table_type='TABLE';
      DBMS_OUTPUT.put_line('表的数据量为:'||c);
    end test_ppp;在命令窗口执行:
    set serverout on;--打开输出开关
    execute test_ppp;--执行上面的存储过程