首页 > 数据库技术 > 详细

Oracle存储过程和函数

时间:2015-11-02 06:44:17      阅读:193      评论:0      收藏:0      [点我收藏+]

  创建一个存储过程:

CREATE OR REPLACE procedure proc_trade( 
  v_tradeid in tt_b.number%TYPE,                        --交易id 
  v_third_ip in tt_b.varchar2%TYPE,                     --第三方ip 
  v_third_time in tt_b.date%TYPE ,                      --第三方完成时间 
   v_thire_state in tt_b.number%TYPE ,                  --第三方状态 
  o_result out tt_b.number%TYPE,                        --返回值 
  o_detail out tt_b.varchar2%TYPE                       --详细描述 
) 
as
   --变量赋值 
   o_result:=0; 
   o_detail:=‘验证失败‘; 
 
   --业务逻辑处理 
    if v_tradeid >100 then 
        insert into table_name(...) values(...); 
        commit; 
    elsif v_tradeid < 100 and v_tradeid>50 then 
        insert into table_name(...) values(...); 
        commit; 
    else 
            goto log; 
    end if; 
   --跳转标志符,名称自己指定 
<<log>> 
        o_result:=1; 
   --捕获异常 
exception 
   when no_data_found 
   then 
      result := 2; 
   when dup_val_on_index 
   then 
      result := 3; 
   when others 
   then 
      result := -1; 
end proc_trade;


Oracle存储过程和函数

原文:http://leboit.blog.51cto.com/1465210/1708677

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!