Form界面同一时间段中相同类型的数据不能同时启用

一、与数据库表中进行对比看能否插入或更改:
代码实现:
1、编写检查重复时间段的package:
PROCEDURE check_date is
 
  v_start_date date;
  v_end_date date;
  v_count number;
 
  CURSOR accrual_date_cur
  is select a.START_DATE,
            a.END_DATE
     from CUX_FIN_CE_FUND_ACCRUALS a
     where a.BALANCE_TYPE_CODE = :CUX_FUND_ACCRUALS_L.BALANCE_TYPE_CODE
     and   a.ACCRUAL_CATEGORY = :CUX_FUND_ACCRUALS_L.ACCRUAL_CATEGORY
     and   a.ENABLE_FLAG = 'Y'
     and   a.ROWID != :CUX_FUND_ACCRUALS_L.ROW_ID;--cursor中需要排除当前需要新增或者修改的这一行记录
    
  begin
       v_count := 0;
       for accrual_date_rec in accrual_date_cur loop
           v_start_date := accrual_date_rec.start_date;
           v_end_date := accrual_date_rec.end_date;
          
         
           --输入结束日期和数据库结束日期都不为空
           if :CUX_FUND_ACCRUALS_L.end_date is not null and v_end_date is not null then
                 if nvl(v_start_date,sysdate) <= :CUX_FUND_ACCRUALS_L.end_date
                        and v_end_date >= nvl(:CUX_FUND_ACCRUALS_L.start_date,sysdate)
                 then
                     --fnd_message.debug('OK');
                         v_count := v_count+1;
                         exit;
                 end if;
         
                 --输入结束日期为为空     
                  elsif :CUX_FUND_ACCRUALS_L.end_date is null then
                                if nvl(v_end_date,sysdate) >= nvl(:CUX_FUND_ACCRUALS_L.start_date,sysdate)
                        then
                                       --fnd_message.debug('OK2');
                                       v_count := v_count+1;
                                       exit;
                      end if;
          
           --数据库结束日期为空时          
                               elsif v_end_date is null then
                                         if nvl(:CUX_FUND_ACCRUALS_L.end_date,sysdate) >= nvl(v_start_date,sysdate)
                                         then
                                        --fnd_message.debug('OK3');
                                                v_count := v_count+1;
                                                exit;
                                         end if;
                      
                       --都为空时
                               elsif v_end_date is null and :CUX_FUND_ACCRUALS_L.end_date is null
                                         then
                                                 v_count := v_count+1;
                                         exit;
                       end if;
       end loop;
      
            if v_count > 0 then
                 fnd_message.debug('同一时间段中的资金类型和费率类型不能相同');
                 raise form_trigger_failure;
                 end if;
           
       end check_date;

2、在块级trigger:on-insert、on-update中调用;


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值