写过的合理验证oracle存储过程PROCEDUREprocedure

本文探讨了在Oracle数据库中编写存储过程PROCEDURE的合理验证方法,包括参数检查、异常处理和性能优化等方面,旨在提升存储过程的稳定性和效率。
摘要由CSDN通过智能技术生成
CREATE OR REPLACE PROCEDURE gwbs_check(vpcbh in t_batch_gwbs_check.pcbh%type) IS

  CURSOR c_tocheck IS
    SELECT * FROM t_batch_gwbs_check c where c.pcbh=vpcbh;--获取待校验的数据
   errorStr varchar2(500);--来拼接每条数据的错误提示
   gw_rows number;
   police_rows number;
   cxfs_rows number;
   cph_rows number;
   qwms_rows number;
   police_deploy_rows number;
   police_leave_rows number;
   todeploy_timeerror_rows number;

   real_qssjd t_batch_gwbs_check.qssj_d%type;
   real_jssjd t_batch_gwbs_check.jssj_d%type;
   
   qssjd t_gwxx_gwsd.qssj%type;
   jssjd t_gwxx_gwsd.jssj%type;
   
   gwsd_rows number;

BEGIN
  DBMS_OUTPUT.PUT_LINE('循环开始时间:'||to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'));
  --待校验游标循环
  FOR c_tocheck_r IN c_tocheck LOOP
    errorStr := '';
    /*根据开始结束时间和岗位时段情况来赋值真正的开始时间和结束时间*/
    if c_tocheck_r.qssj_d is not null and c_tocheck_r.jssj_d is not null and c_tocheck_r.gwsdid is not null
      then 
        errorStr := concat(errorStr,'起始结束时间和岗位时段必须二选一;');
        goto updateTable;
    elsif c_tocheck_r.qssj_d is null and c_tocheck_r.jssj_d is null and c_tocheck_r.gwsdid is null
      then errorStr := concat(errorStr,'起始结束时间和岗位时段必须二选一;');
        goto updateTable;
    elsif (c_tocheck_r.qssj_d is null and c_tocheck_r.jssj_d is not null) or (c_tocheck_r.qssj_d is not null and c_tocheck_r.jssj_d is null)
      then errorStr := concat(errorStr,'起始时间和结束时间不能只能选一个;');
        goto updateTable;
    elsif c_tocheck_r.qssj_d is not null and c_tocheck_r.jssj_d is not null and c_tocheck_r.gwsdid is null
      then 
        real_qssjd := c_toc
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值