ORACLE存储过程plsql创建与执行(一)

来源:互联网 发布:知乎电子书在电脑上看 编辑:程序博客网 时间:2024/06/06 20:17
  1. 关键字说明
    a)创建参数的in \ out \in out说明
    IN:传入参数进PROCEDURE给存储过程用;
    OUT:将存储过程处理的结果传出来;
    IN OUT:传入参数给存储过程,再将处理后的结果传出来;
    b)PLSQL如何运行带参数的存储过程
    打开test windows ——》
    *declare
    v_city varchar2(100);
    begin
    test_xxx(‘a’,v_city);
    dbms_output.put_line(v_city); – 打印返回结果(DBMS Output中查看)
    end;*
  2. 创建存储过程及执行调试
    a)创建
     create or replace procedure test_xxx(inputterm in varchar2, return_value out varchar2) isbegin     return_value:='yes';     execute immediate 'truncate table  a' ;     --delete from a      insert into a (            id     -- 编号     )     select id_b     from b  commit;exception      when others then           return_value:=substr(sqlerrm,1,300);     rollback;end test_xxx;
b)执行
   declare   v_city varchar2(100);begin  test_xxx('a',v_city);    --dbms_output.put(v_city);  dbms_output.put_line(v_city);-- 查看返回结果end;
0 0
原创粉丝点击