15存储过程

一、无参的存储过程

create or replace procedure proc_one is
begin
  dbms_output.put_line('hello');
end proc_one;
/

二、带参的存储过程

create or replace procedure Proc_Two
--定义参数时,不能指定长度。
(in_i in number, in_j in number, out_k out varchar2) is
  v_k number;
begin
  v_k := in_i + in_j;

  out_k := to_char(v_k);

end Proc_Two;
/
三、调用存储过程的方式

--调用过程的3种方式

--1:使用命令窗口
     --set serveroutput on ---开启控制台的输出功能。
     --execute proc_one();
     
     --execute 比较适用于过程无参数或者只有输入参数的类型。
     
--2:使用PLSQL程序
declare

begin
    proc_one();
end;


declare
  v_str varchar2(100);
begin
  proc_two(in_i => 10,in_j => 20,out_k => v_str);
  
  dbms_output.put_line('v_str = ' || v_str);
end;

--3:使用java代码

四、带参的过程

/*
* Classinfo这张表
  
 */
create or replace procedure Proc_Three

(in_classid in number, out_result out varchar2) is
  v_parentid varchar2(10);
begin
  select parentid
    into v_parentid
    from T_Classinfo
   where classid = in_classid;

  if v_parentid = '0' then
    --大类别
    Delete From T_Classinfo where parentid = in_classid;
  else
    --小类别
    null;
  end if;
  Delete From T_Classinfo where classid = in_classid;
  commit;
exception
  when others then
    begin
      dbms_output.put_line('程序异常 = ' || SQLErrm);
      rollback;
    end;
end Proc_Three;
/
五、










  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值