DBA Data[Home] [Help]

APPS.BEN_DET_IMPUTED_INCOME SQL Statements

The following lines contain the word 'select', 'insert', 'update' or 'delete':

Line: 11

rate starting before the earliest coverage start date of plan subject to imputed income should be deleted, because
it would be corresponding to the plan that got de-enrolled. procedure delete_past_imp is used for this purpose
*/
procedure delete_past_imp(p_person_id         number,
                          p_per_in_ler_id     number,
                          p_business_group_id number,
                          p_effective_date    date,
                          p_erlst_cvg_strt    date,
                          p_imptd_incm_calc_cd varchar2)
is

--cursor to fetch imputed income plans
cursor c_imp_inc_plan(p_imptd_incm_calc_cd varchar2, p_business_group_id number, p_effective_date date)
is
    select pln.pl_id
    from   ben_pl_f pln
    where  pln.imptd_incm_calc_cd = p_imptd_incm_calc_cd
    and    pln.pl_stat_cd = 'A'
    and    pln.business_group_id = p_business_group_id
    and    p_effective_date between pln.effective_start_date and  pln.effective_end_date;
Line: 37

    select prv.*
    from ben_prtt_rt_val prv, ben_per_in_ler pil
    where pil.person_id = p_person_id
    and prv.per_in_ler_id = p_per_in_ler_id
    and prv.per_in_ler_id = pil.per_in_ler_id
    and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
    and prv.prtt_enrt_rslt_id in (select pen.prtt_enrt_rslt_id
                                    from ben_prtt_enrt_rslt_f pen, ben_per_in_ler pil
                                    where pil.person_id = p_person_id
                                    and pen.per_in_ler_id = pil.per_in_ler_id
                                    and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
                                    and pen.pl_id = l_pl_id
                                    and pen.per_in_ler_id = p_per_in_ler_id
                                    and pen.prtt_enrt_rslt_stat_cd is NULL)
    and prv.rt_strt_dt < p_erlst_cvg_strt
    order by prv.rt_strt_dt desc ;
Line: 57

l_proc    varchar2(72) := g_package||'delete_past_imp';
Line: 81

             hr_utility.set_location (' delete past rate prv', 2);
Line: 85

             update ben_enrt_rt set prtt_rt_val_id = NULL
             where prtt_rt_val_id = nvl(l_imp_inc_rt_tab(r).prtt_rt_val_id,-1);
Line: 90

             ben_prtt_rt_val_api.delete_prtt_rt_val
                  (p_validate                       => false
                  ,p_prtt_rt_val_id                 => l_imp_inc_rt_tab(r).prtt_rt_val_id
                  ,p_enrt_rt_id                     => NULL
                  ,p_person_id                      => p_person_id
                  ,p_business_group_id              => p_business_group_id
                  ,p_object_version_number          => l_imp_inc_rt_tab(r).object_version_number
                  ,p_effective_date                 => l_imp_inc_rt_tab(r).rt_strt_dt);
Line: 101

END delete_past_imp;
Line: 103

/* 8716870: procedure delete_imp_inc is addded to delete the future rate and enrollment for imputed shell plan */

procedure delete_imp_inc(p_person_id         number,
                         p_per_in_ler_id     number,
                         p_business_group_id number,
                         p_effective_date    date,
                         p_imptd_incm_calc_cd varchar2)
is

  l_proc       varchar2(60) := g_package||'.delete_imp_inc';
Line: 114

  l_delete                boolean;
Line: 116

  l_delete_next_change    boolean;
Line: 128

        select pln.pl_id
        from   ben_pl_f pln
        where  pln.imptd_incm_calc_cd = p_imptd_incm_calc_cd
        and    pln.pl_stat_cd = 'A'
        and    pln.business_group_id = p_business_group_id
        and    p_effective_date between pln.effective_start_date and  pln.effective_end_date;
Line: 138

    select pen.*
    from ben_prtt_enrt_rslt_f pen, ben_per_in_ler pil
    where pil.person_id = p_person_id
    and pen.per_in_ler_id = p_per_in_ler_id
    and pen.per_in_ler_id = pil.per_in_ler_id
    and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
    and pen.pl_id = l_pl_id
    and pen.enrt_cvg_strt_dt > p_effective_date
    order by pen.effective_start_date, pen.enrt_cvg_strt_dt desc ;
Line: 153

    select prv.*
    from ben_prtt_rt_val prv, ben_per_in_ler pil
    where pil.person_id = p_person_id
    and prv.per_in_ler_id = p_per_in_ler_id
    and prv.per_in_ler_id = pil.per_in_ler_id
    and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
    and prv.prtt_enrt_rslt_id in (select pen.prtt_enrt_rslt_id
                                    from ben_prtt_enrt_rslt_f pen, ben_per_in_ler pil
                                    where pil.person_id = p_person_id
                                    and pen.per_in_ler_id = pil.per_in_ler_id
                                    and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
                                    and pen.pl_id = l_pl_id
                                    and pen.per_in_ler_id = p_per_in_ler_id
									and pen.enrt_cvg_strt_dt > p_effective_date --Bug 14559387
                                    and pen.prtt_enrt_rslt_stat_cd is NULL)
   -- and prv.rt_strt_dt > p_effective_date
    and prv.rt_strt_dt > = p_effective_date	--Bug 14559387
    order by prv.rt_strt_dt desc ;
Line: 177

    select 1
    from ben_prtt_enrt_rslt_f pen
    where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
    and pen.per_in_ler_id <> p_per_in_ler_id
    and p_effective_date between pen.effective_start_date and pen.effective_end_date
    and pen.enrt_cvg_thru_dt = hr_api.g_eot;
Line: 189

    select prtt_enrt_rslt_id,per_in_ler_id,pl_typ_id,pl_id
    from ben_prtt_enrt_rslt_f
    where prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
    and per_in_ler_id = p_per_in_ler_id
    and prtt_enrt_rslt_Stat_cd is NULL;
Line: 207

    select pen.*
    from ben_prtt_enrt_rslt_f pen
    where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
    and p_effective_date between pen.effective_start_date and pen.effective_end_date
    and pen.prtt_enrt_rslt_stat_cd is NULL
    order by pen.prtt_enrt_rslt_id, pen.effective_start_date desc;
Line: 216

    select lcnr.*
    from BEN_LE_CLSN_N_RSTR  lcnr
    where lcnr.bkup_tbl_id          = l_prtt_enrt_rslt_id
      and lcnr.BKUP_TBL_TYP_CD      = 'BEN_PRTT_ENRT_RSLT_F_CORR'
      and lcnr.enrt_cvg_thru_dt     = hr_api.g_eot
      and  lcnr.Per_in_ler_ended_id = l_per_in_ler_id;
Line: 250

	     hr_utility.set_location (' delete future rate prv', 2);
Line: 254

             update ben_enrt_rt set prtt_rt_val_id = NULL
             where prtt_rt_val_id = nvl(l_imp_inc_rt_tab(r).prtt_rt_val_id,-1);
Line: 259

             ben_prtt_rt_val_api.delete_prtt_rt_val
                  (p_validate                       => false
                  ,p_prtt_rt_val_id                 => l_imp_inc_rt_tab(r).prtt_rt_val_id
                  ,p_enrt_rt_id                     => NULL
                  ,p_person_id                      => p_person_id
                  ,p_business_group_id              => p_business_group_id
                  ,p_object_version_number          => l_imp_inc_rt_tab(r).object_version_number
                  ,p_effective_date                 => l_imp_inc_rt_tab(r).rt_strt_dt);
Line: 285

             hr_utility.set_location (' delete imputed enrollment', 2);
Line: 302

                l_delete             := null;
Line: 304

                l_delete_next_change := null;
Line: 313

                   p_delete              => l_delete,
                   p_future_change       => l_future_change,
                   p_delete_next_change  => l_delete_next_change);
Line: 320

                elsif l_delete_next_change then
                  --
                  l_mode := hr_api.g_delete_next_change;
Line: 327

                l_imp_inc_enrt_tab_prior.delete;
Line: 358

                   update ben_prtt_enrt_rslt_f
                   set    ler_id = l_corr_pen_rec.ler_id,
                          per_in_ler_id = l_corr_pen_rec.per_in_ler_id
                   where prtt_enrt_rslt_id = l_corr_pen_rec.bkup_tbl_id
                   and effective_start_date = l_corr_pen_rec.effective_start_date
                   and exists (select 1
                                from ben_per_in_ler
                               where per_in_ler_id = l_corr_pen_rec.per_in_ler_id
                                 and per_in_ler_stat_cd not in ('BCKDT','VOIDD'))
                   and business_group_id = p_business_group_id
                   and person_id = l_corr_pen_rec.person_id;
Line: 371

                      delete from BEN_LE_CLSN_N_RSTR
    		       where bkup_tbl_id       = nvl(l_corr_pen_rec.bkup_tbl_id,-1)
    		         and Per_in_ler_ended_id = nvl(l_imp_inc_enrt_tab(r).per_in_ler_id,-1)
                         and BKUP_TBL_TYP_CD   = 'BEN_PRTT_ENRT_RSLT_F_CORR';
Line: 382

                   ben_prtt_enrt_result_api.delete_prtt_enrt_result
        	             (p_validate                => false,
        	              p_prtt_enrt_rslt_id       => l_delrec.prtt_enrt_rslt_id,
        		      p_effective_start_date    => l_effective_start_date,
        		      p_effective_end_date      => l_effective_end_date,
        		      p_object_version_number   => l_object_version_number,
        		      p_effective_date          => l_delrec.effective_start_date,
        		      p_datetrack_mode          => l_mode,
        		      p_multi_row_validate      => FALSE);
Line: 396

              	ben_prtt_enrt_result_api.delete_prtt_enrt_result
        	             (p_validate                => false,
        	              p_prtt_enrt_rslt_id       => l_delrec.prtt_enrt_rslt_id,
        	              p_effective_start_date    => l_effective_start_date,
        	              p_effective_end_date      => l_effective_end_date,
        	              p_object_version_number   => l_object_version_number,
        	              p_effective_date          => l_delrec.effective_start_date,
        	              p_datetrack_mode          => l_mode,
        	              p_multi_row_validate      => FALSE);
Line: 413

end delete_imp_inc;
Line: 431

    select pil.lf_evt_ocrd_dt,
           pil.ler_id
    from   ben_per_in_ler pil
    where  pil.per_in_ler_id = p_per_in_ler_id;
Line: 444

     select prv.rt_val , prv.tx_typ_cd,prv.acty_typ_cd
     from   ben_prtt_enrt_rslt_f pen,
            ben_prtt_rt_val prv,
            ben_acty_base_rt_f abr,
            ben_pl_f pln,
            ben_per_in_ler pil
     where  pen.person_id = p_person_id
     and    pen.prtt_enrt_rslt_stat_cd is null
     and    pen.enrt_cvg_thru_dt = p_eot
     and    pen.business_group_id = p_business_group_id
     and    pen.pl_id = pln.pl_id
     and    pen.sspndd_flag = 'N'
     and    pln.subj_to_imptd_incm_typ_cd =p_subj_to_imptd_incm_typ_cd
     and    pln.pl_stat_cd = 'A'
     and    pln.business_group_id = p_business_group_id
     and    prv.PRTT_RT_VAL_STAT_CD is null
     --and    prv.per_in_ler_id = pen.per_in_ler_id
     and    prv.Rt_end_dt  =   p_eot
     and    prv.per_in_ler_id = pil.per_in_ler_id
     and    pil.per_in_ler_stat_cd not in ('BCKDT','VOIDD')
     and    p_effective_date between pln.effective_start_date
            and pln.effective_end_date
     and    prv.prtt_enrt_rslt_id = pen.prtt_enrt_rslt_id
     AND    pen.effective_end_date=hr_api.g_eot
     and    l_max_le_eff_date >= least(pen.effective_start_date,pen.enrt_cvg_strt_dt )
     and   abr.acty_base_rt_id  = prv.acty_base_rt_id
     and   abr.subj_to_imptd_incm_flag  = 'Y'
     and   l_max_le_eff_date   between  abr.effective_start_date and abr.effective_end_date ;
Line: 480

     select sum(pen.bnft_amt)
     from   ben_prtt_enrt_rslt_f pen,
	    ben_pl_f pln,
            ben_per_in_ler pil
     where  pen.person_id = p_person_id
     and    pen.prtt_enrt_rslt_stat_cd is null
     and    pen.enrt_cvg_thru_dt = p_eot
     and    pen.business_group_id = p_business_group_id
     and    pen.pl_id = pln.pl_id
     and    pen.sspndd_flag = 'N'
     and    pln.subj_to_imptd_incm_typ_cd =p_subj_to_imptd_incm_typ_cd
     and    pln.pl_stat_cd = 'A'
     and    pln.business_group_id = p_business_group_id
     and    pil.per_in_ler_stat_cd not in ('BCKDT','VOIDD')
     and    p_effective_date between pln.effective_start_date
	    and pln.effective_end_date
-- Bug # - 1675410 - If the coverage start date is after life event occurred date,
-- the above condition does not select result row. As much as per_in_ler_id is
-- existing in pen, it is better to join pil with pen  by per_in_ler_id
     and    pil.per_in_ler_id = pen.per_in_ler_id
     AND    pen.effective_end_date=hr_api.g_eot
 -- Bug 1884964 to restrict pen records from different set
     and    l_max_le_eff_date >= least(pen.effective_start_date,pen.enrt_cvg_strt_dt )
     and exists
           (select 'x'
              from ben_elig_per_f pep
             where pep.pl_id=pen.pl_id
               and nvl(pep.pgm_id,-1)=nvl(pen.pgm_id,-1)
               and pep.person_id=pen.person_id
               and pep.per_in_ler_id = pil.per_in_ler_id
               and pep.pl_hghly_compd_flag = p_highly_comp
               and pep.prtn_strt_dt <= greatest(pen.enrt_cvg_strt_dt,l_max_le_eff_date)
               and pep.business_group_id = pen.business_group_id);
Line: 543

     select sum(pen.bnft_amt)
     from   ben_prtt_enrt_rslt_f pen,
	    ben_pl_f pln,
            ben_per_in_ler pil
     where  pen.person_id = p_person_id
     and    pen.prtt_enrt_rslt_stat_cd is null
--     and    pen.enrt_cvg_thru_dt = p_eot
     and    pen.business_group_id = p_business_group_id
     and    pen.pl_id = pln.pl_id
     and    pen.sspndd_flag = 'N'
     and    pln.subj_to_imptd_incm_typ_cd =p_subj_to_imptd_incm_typ_cd
     and    pln.pl_stat_cd = 'A'
     and    pln.business_group_id = p_business_group_id
     and    pil.per_in_ler_stat_cd not in ('BCKDT','VOIDD')
     and    p_imp_cvg_strt_dt between pln.effective_start_date
	    and pln.effective_end_date      -- Bug 9436910
-- Bug # - 1675410 - If the coverage start date is after life event occurred date,
-- the above condition does not select result row. As much as per_in_ler_id is
-- existing in pen, it is better to join pil with pen  by per_in_ler_id
     and    pil.per_in_ler_id = pen.per_in_ler_id
     AND    pen.effective_end_date=hr_api.g_eot
 -- Bug 1884964 to restrict pen records from different set
     and    l_max_le_eff_date >= least(pen.effective_start_date,pen.enrt_cvg_strt_dt )
     and    p_cvg_strt_dt between pen.enrt_cvg_strt_dt and pen.enrt_cvg_thru_dt
     and exists
           (select 'x'
              from ben_elig_per_f pep
             where pep.pl_id=pen.pl_id
               and nvl(pep.pgm_id,-1)=nvl(pen.pgm_id,-1)
               and pep.person_id=pen.person_id
               and pep.per_in_ler_id = pil.per_in_ler_id
               and pep.pl_hghly_compd_flag = p_highly_comp
               and pep.prtn_strt_dt <= greatest(pen.enrt_cvg_strt_dt,l_max_le_eff_date)
               and pep.business_group_id = pen.business_group_id);
Line: 607

    select pln.pl_id,
           pln.pl_cd
    from   ben_pl_f pln
    where  pln.imptd_incm_calc_cd = p_imptd_incm_calc_cd
    and    pln.pl_stat_cd = 'A'
    and    pln.business_group_id = p_business_group_id
    and    p_effective_date
           between pln.effective_start_date
           and     pln.effective_end_date;
Line: 618

    select pen.prtt_enrt_rslt_id,
           pen.object_version_number,
           pen.pl_id,
           pen.oipl_id,
           pen.pgm_id,
           pen.effective_start_date,   -- 8716870
           pen.pl_typ_id
    from   ben_prtt_enrt_rslt_f pen
    where  pen.business_group_id = p_business_group_id and
           pen.prtt_enrt_rslt_stat_cd is null and
          pen.pl_id = p_pl_id and
          pen.oipl_id is null and
          pen.person_id = p_person_id
     AND    l_pil_rec.lf_evt_ocrd_dt between
            pen.enrt_cvg_strt_dt and pen.enrt_cvg_thru_dt
     AND    pen.effective_end_date=hr_api.g_eot;
Line: 636

    select pen.prtt_enrt_rslt_id,
           pen.object_version_number,
           pen.pl_id,
           pen.oipl_id,
           pen.pgm_id,
           pen.effective_start_date,                 -- 8716870
           pen.pl_typ_id
    from   ben_pl_f pln,
           ben_prtt_enrt_rslt_f pen
    where  pln.imptd_incm_calc_cd = p_imptd_incm_calc_cd
    and    pln.pl_stat_cd = 'A'
    and    p_effective_date
           between pln.effective_start_date
           and     pln.effective_end_date
    and    pen.business_group_id = p_business_group_id
    and    pen.prtt_enrt_rslt_stat_cd is null
    and    pen.pl_id = pln.pl_id
    and    pen.oipl_id is null
    and    pen.person_id = p_person_id
/* 8716870 code changes */
--  and    pen.effective_end_date = hr_api.g_eot
--  and    pen.enrt_cvg_thru_dt = hr_api.g_eot;
Line: 663

    select epe.ELIG_PER_ELCTBL_CHC_ID,
	   epe.PL_ID,
	   epe.OIPL_ID,
	   epe.PGM_ID,
	   epe.PL_TYP_ID,
	   epe.PER_IN_LER_ID,
           nvl(epe.prtt_enrt_rslt_id,-1) prtt_enrt_rslt_id
           from   ben_elig_per_elctbl_chc epe
           where  epe.per_in_ler_id = p_per_in_ler_id
           and    epe.business_group_id = p_business_group_id
           and    epe.pl_id = p_pl_id
           and    epe.oipl_id is null
           order by prtt_enrt_rslt_id desc;
Line: 678

    select ecr.enrt_rt_id,
           ecr.acty_base_rt_id,
           ecr.prtt_rt_val_id
    from ben_enrt_rt ecr
    where  ecr.elig_per_elctbl_chc_id = p_elig_per_elctbl_chc_id and
           ecr.business_group_id = p_business_group_id
           and ecr.rt_usg_cd = 'IMPTDINC';
Line: 688

    select prv.prtt_rt_val_id,
           prv.acty_base_rt_id,
           prv.rt_ovridn_flag,     -- Bug 2200139 Override changes
           prv.rt_ovridn_thru_dt   -- Bug 2200139 Override changes
    from   ben_prtt_rt_val prv
    where  prv.business_group_id          = p_business_group_id
    and    prv.prtt_enrt_rslt_id          = p_prtt_enrt_rslt_id
    and    prv.prtt_rt_val_stat_cd is null
    and    prv.rt_end_dt  = hr_api.g_eot;
Line: 699

    select null
    from   ben_prtt_enrt_rslt_f pen,
           ben_pl_f pln
    where  pen.business_group_id = p_business_group_id
    and    pen.prtt_enrt_rslt_stat_cd is null
    and    pen.pgm_id = p_pgm_id
    and    pen.person_id = p_person_id
    and    pen.enrt_cvg_thru_dt =  hr_api.g_eot
    and    pen.effective_end_date= hr_api.g_eot
    and    pln.pl_id = pen.pl_id
    and    pln.subj_to_imptd_incm_typ_cd =p_subj_to_imptd_incm_typ_cd
    and    pln.pl_stat_cd = 'A'
    and    pln.business_group_id = p_business_group_id
    and    p_effective_date between pln.effective_start_date
    and    pln.effective_end_date;
Line: 716

     select acty_base_rt_id
     from    ben_acty_base_rt_f abr
     where   abr.pl_id=p_plan_id
     and     p_effective_date between abr.effective_start_date  and abr.effective_end_date
     and     abr.business_group_id = p_business_group_id ;
Line: 724

     select b.mlt_cd  from
        ben_acty_vrbl_rt_f a   ,
        ben_vrbl_rt_prfl_f b
        where
             a.acty_base_rt_id = p_abr_id
        and  a.vrbl_rt_prfl_id  = b.vrbl_rt_prfl_id
        and a.business_group_id  =p_business_group_id
        and p_effective_date between a.effective_start_date and a.effective_end_date
        and p_effective_date between b.effective_start_date and b.effective_end_date
        and  ( mlt_cd  not in ('FLFX' , 'RL') or  VRBL_RT_TRTMT_CD <> 'RPLC' )
        ;
Line: 742

    select pil.lf_evt_ocrd_dt, popl.elcns_made_dt, popl.dflt_asnd_dt, popl.dflt_enrt_dt
    from ben_per_in_ler pil, ben_pil_elctbl_chc_popl popl
    where popl.per_in_ler_id (+) = pil.per_in_ler_id
    and pil.per_in_ler_id = p_per_in_ler_id;
Line: 753

    select epe.ELIG_PER_ELCTBL_CHC_ID,
           epe.pgm_id,
           epe.pl_typ_id,
           epe.pl_id,
           epe.fonm_cvg_strt_dt
    from ben_elig_per_elctbl_chc epe,
        ben_per_in_ler pil,
         ben_pl_f pl,
         ben_pil_elctbl_chc_popl pel                  /* bug 10262697 */
    where epe.PER_IN_LER_ID = p_per_in_ler_id
    and pil.per_in_ler_id = p_per_in_ler_id
    and pil.per_in_ler_stat_cd not in ('BCKDT','VOIDD')
    and epe.pl_id = pl.pl_id
    and pel.pil_elctbl_chc_popl_id = epe.pil_elctbl_chc_popl_id    /* bug 10262697 */
    and p_effective_date between pl.effective_start_date and pl.effective_end_date
    and pl.imptd_incm_calc_cd = p_imptd_incm_calc_cd;
Line: 859

  l_datetrack_mode                varchar2(30) :=  'INSERT';
Line: 953

    hr_utility.set_location (' calling  delete_imp_inc with effective date as l_rt_strt_dt ', 2);
Line: 954

    delete_imp_inc(p_person_id          => p_person_id,
                   p_per_in_ler_id      => p_per_in_ler_id,
                   p_business_group_id  => p_business_group_id,
                   p_effective_date     => nvl(l_rt_strt_dt,l_cvg_strt_dt),
                   p_imptd_incm_calc_cd => p_subj_to_imptd_incm_typ_cd);
Line: 1396

          ben_provider_pools.update_rate
            (p_prtt_rt_val_id      => l_ecr_prv_rec.prtt_rt_val_id,
             p_val                 => rate_val_list(l_count),
             p_prtt_enrt_rslt_id   => l_enrt_rslt_rec.prtt_enrt_rslt_id,
             p_business_group_id   => p_business_group_id,
             p_ended_per_in_ler_id => p_per_in_ler_id,
             p_effective_date      => p_effective_date);
Line: 1433

      fnd_message.set_token('PROC','ben_election_information -update');
Line: 1490

      fnd_message.set_token('PROC','ben_election_information-insert');
Line: 1594

        ben_prtt_enrt_result_api.delete_enrollment
          (p_prtt_enrt_rslt_id     => l_enrt_rslt_rec.prtt_enrt_rslt_id,
           p_per_in_ler_id         => p_per_in_ler_id,
           p_object_version_number => l_enrt_rslt_rec.object_version_number,
           p_effective_start_date  => l_effective_start_date,
           p_effective_end_date    => l_effective_end_date,
           p_effective_date        => l_eff_date_for_enrt,       --8716870
           p_datetrack_mode        => hr_api.g_delete,
           p_business_group_id     => p_business_group_id,
           p_source                => 'bendeimp',
           p_multi_row_validate    => FALSE);
Line: 1661

  select pen.prtt_enrt_rslt_id, pen.enrt_cvg_strt_Dt,pl.subj_to_imptd_incm_typ_cd
  from   ben_prtt_enrt_rslt_f pen,
         ben_per_in_ler pil,
         ben_pl_f pl
  where  pen.pl_id = pl.pl_id
    and  pen.sspndd_flag = 'N'
    and  pen.per_in_ler_id = pil.per_in_ler_id
    and  pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
    and  pen.person_id = pil.person_id
    and  pen.prtt_enrt_rslt_stat_cd is NULL
    and  p_effective_date between pl.effective_start_date and pl.effective_end_date
    /* Bug 13399004 : Commented the below two coniditons*/
    --and  pen.enrt_cvg_thru_dt = hr_api.g_eot
    --and  pen.effective_end_date = hr_api.g_eot
--    and  p_effective_date between pen.enrt_cvg_strt_dt and pen.enrt_cvg_thru_dt
    and  pen.person_id = p_person_id
  --and  pil.person_id = p_person_id
    and  pil.per_in_ler_id  = p_per_in_ler_id
    and  subj_to_imptd_incm_typ_cd is not null
  union
  select pen.prtt_enrt_rslt_id, pen.enrt_cvg_strt_Dt,pl.subj_to_imptd_incm_typ_cd
  from   ben_prtt_enrt_rslt_f pen,
         ben_elig_per_elctbl_chc epe,
         ben_pl_f pl,
         ben_per_in_ler pil
  where  epe.per_in_ler_id <> pen.per_in_ler_id
    and  pen.pl_id = pl.pl_id
    and  epe.prtt_enrt_rslt_id = pen.prtt_enrt_rslt_id
    and  epe.per_in_ler_id = pil.per_in_ler_id
    and  nvl(epe.pl_id,-1) = nvl(pen.pl_id,-1)
    and  nvl(epe.oipl_id,-1) = nvl(pen.oipl_id,-1)
    and  epe.elctbl_flag = 'N'
    and  epe.crntly_enrd_flag = 'Y'
    and  pen.sspndd_flag = 'N'
    and  pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
    and  pen.prtt_enrt_rslt_stat_cd is NULL
    and  p_effective_date between pl.effective_start_date and pl.effective_end_date
--    and  p_effective_date between pen.enrt_cvg_strt_dt and pen.enrt_cvg_thru_dt
    and  pen.enrt_cvg_thru_dt = hr_api.g_eot
    and  pen.effective_end_date = hr_api.g_eot
    and  pen.person_id = pil.person_id
    and  pen.person_id = p_person_id
    and  epe.per_in_ler_id = p_per_in_ler_id
    and  pl.subj_to_imptd_incm_typ_cd is not null
  order  by 2 ;
Line: 1716

  select pen.prtt_enrt_rslt_id, pen.enrt_cvg_strt_Dt,pl.subj_to_imptd_incm_typ_cd
  from   ben_prtt_enrt_rslt_f pen,
         ben_per_in_ler pil,
         ben_pl_f pl
  where  pen.pl_id = pl.pl_id
    and  pen.sspndd_flag = 'N'
    and  pen.per_in_ler_id = pil.per_in_ler_id
    and  pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
    and  pen.person_id = pil.person_id
    and  pen.prtt_enrt_rslt_stat_cd is NULL
    and  p_effective_date between pl.effective_start_date and pl.effective_end_date
    and  pen.enrt_cvg_thru_dt = hr_api.g_eot
    and  pen.effective_end_date = hr_api.g_eot
    and  pen.person_id = p_person_id
    and  pil.person_id = p_person_id
    and  pil.per_in_ler_id  = p_per_in_ler_id
    and  pl.subj_to_imptd_incm_typ_cd = p_imptd_incm_typ_cd
  order  by 2;
Line: 1739

   select ler.typ_cd
   from  ben_per_in_ler pil , ben_ler_f ler
   where per_in_ler_id = p_per_in_ler_id
   and   ler.ler_id = pil.ler_id
   and   lf_evt_ocrd_dt between ler.effective_start_date and ler.effective_end_date;
Line: 1754

    select pen.prtt_enrt_rslt_id,
           pen.object_version_number,
           pen.pl_id,
           pen.oipl_id,
           pen.pgm_id,
           pen.effective_start_date,
           pen.pl_typ_id,
           pen.enrt_cvg_strt_dt
    from   ben_pl_f pln,
           ben_prtt_enrt_rslt_f pen
    where  pln.imptd_incm_calc_cd = c_imp_inc_cd     -- bug 12354818
    and    pln.pl_stat_cd = 'A'
    and    p_effective_date between pln.effective_start_date and pln.effective_end_date
    and    pen.business_group_id = p_business_group_id
    and    pen.prtt_enrt_rslt_stat_cd is null
    and    pen.pl_id = pln.pl_id
    and    pen.oipl_id is null
    and    pen.person_id = p_person_id
    and    pen.effective_end_date = hr_api.g_eot
    and    pen.enrt_cvg_thru_dt = hr_api.g_eot;
Line: 1787

  select pen.prtt_enrt_rslt_id,
         pen.enrt_cvg_strt_Dt,
         pl.subj_to_imptd_incm_typ_cd
  from   ben_prtt_enrt_rslt_f pen,
         ben_per_in_ler pil,
         ben_pl_f pl
  where  pen.pl_id = pl.pl_id
    and  pen.sspndd_flag = 'N'
    and  pen.per_in_ler_id = pil.per_in_ler_id
    and  pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
    and  pen.person_id = pil.person_id
    and  pen.prtt_enrt_rslt_stat_cd is NULL
    and  p_effective_date between pl.effective_start_date and pl.effective_end_date
    and  pen.enrt_cvg_thru_dt = hr_api.g_eot
    and  pen.effective_end_date = hr_api.g_eot
--    and  p_effective_date between pen.enrt_cvg_strt_dt and pen.enrt_cvg_thru_dt
    and  pen.person_id = p_person_id
--    and  pil.per_in_ler_id  = p_per_in_ler_id
    and  subj_to_imptd_incm_typ_cd = c_imp_inc_cd ; /* bug 12354818 */
Line: 1854

         delete_past_imp(p_person_id          => p_person_id,
                         p_per_in_ler_id      => p_per_in_ler_id,
                         p_business_group_id  => p_business_group_id,
                         p_effective_date     => p_effective_date,
                         p_erlst_cvg_strt     => l_erlst_cvg_strt.enrt_cvg_strt_dt,
                         p_imptd_incm_calc_cd => 'PRTT');
Line: 1875

         delete_past_imp(p_person_id          => p_person_id,
                         p_per_in_ler_id      => p_per_in_ler_id,
                         p_business_group_id  => p_business_group_id,
                         p_effective_date     => p_effective_date,
                         p_erlst_cvg_strt     => l_erlst_cvg_strt.enrt_cvg_strt_dt,
                         p_imptd_incm_calc_cd => 'DPNT');
Line: 1896

         delete_past_imp(p_person_id          => p_person_id,
                         p_per_in_ler_id      => p_per_in_ler_id,
                         p_business_group_id  => p_business_group_id,
                         p_effective_date     => p_effective_date,
                         p_erlst_cvg_strt     => l_erlst_cvg_strt.enrt_cvg_strt_dt,
                         p_imptd_incm_calc_cd => 'SPS');
Line: 1996

         ben_prtt_enrt_result_api.delete_enrollment
             (p_prtt_enrt_rslt_id     => l_imp_shell_enrt.prtt_enrt_rslt_id,
              p_per_in_ler_id         => p_per_in_ler_id,
              p_object_version_number => l_imp_shell_enrt.object_version_number,
              p_effective_start_date  => l_effective_start_date,
              p_effective_end_date    => l_effective_end_date,
              p_effective_date        => p_effective_date,
              p_datetrack_mode        => hr_api.g_delete,
              p_business_group_id     => p_business_group_id,
              p_source                => 'bendeimp',
              p_multi_row_validate    => FALSE);
Line: 2024

         ben_prtt_enrt_result_api.delete_enrollment
          (p_prtt_enrt_rslt_id     => l_imp_shell_enrt.prtt_enrt_rslt_id,
           p_per_in_ler_id         => p_per_in_ler_id,
           p_object_version_number => l_imp_shell_enrt.object_version_number,
           p_effective_start_date  => l_effective_start_date,
           p_effective_end_date    => l_effective_end_date,
           p_effective_date        => p_effective_date,
           p_datetrack_mode        => hr_api.g_delete,
           p_business_group_id     => p_business_group_id,
           p_source                => 'bendeimp',
           p_multi_row_validate    => FALSE);
Line: 2052

         ben_prtt_enrt_result_api.delete_enrollment
          (p_prtt_enrt_rslt_id     => l_imp_shell_enrt.prtt_enrt_rslt_id,
           p_per_in_ler_id         => p_per_in_ler_id,
           p_object_version_number => l_imp_shell_enrt.object_version_number,
           p_effective_start_date  => l_effective_start_date,
           p_effective_end_date    => l_effective_end_date,
           p_effective_date        => p_effective_date,
           p_datetrack_mode        => hr_api.g_delete,
           p_business_group_id     => p_business_group_id,
           p_source                => 'bendeimp',
           p_multi_row_validate    => FALSE);
Line: 2096

    select 'Y'
    from   ben_pl_f pln
    where  pln.imptd_incm_calc_cd is not null
    and    pln.pl_stat_cd = 'A'
    and    pln.business_group_id = p_business_group_id
    and    p_effective_date
           between pln.effective_start_date
           and     pln.effective_end_date;
Line: 2110

    select 'Y'
    from   ben_pl_f pln,
           ben_elig_per_elctbl_chc epe
    where  pln.subj_to_imptd_incm_typ_cd is not null
    and    pln.pl_id = epe.pl_id
    and    epe.per_in_ler_id  = p_per_in_ler_id
    and    pln.pl_stat_cd = 'A'
    and    pln.business_group_id = p_business_group_id
    and    p_effective_date
           between pln.effective_start_date
           and     pln.effective_end_date;
Line: 2123

    select 'Y'
    from   ben_prtt_enrt_rslt_f pen
    where  pen.person_id = p_person_id
    and    pen.comp_lvl_cd = 'PLANIMP'
    and    pen.effective_end_date = to_date('31-12-4712','dd-mm-yyyy')
    and    pen.prtt_enrt_rslt_stat_cd is null
    and    pen.enrt_cvg_thru_dt = to_date('31-12-4712','dd-mm-yyyy')
    and    exists (select null from ben_elig_per_elctbl_chc epe
                   where pen.pl_id = epe.pl_id
                   and   epe.per_in_ler_id = p_per_in_ler_id);
Line: 2146

    select 'Y'
    from   ben_prtt_enrt_rslt_f pen, ben_pl_f pl
    where  pen.person_id = p_person_id
      and  pen.comp_lvl_cd = 'PLANIMP'
      and  pen.effective_end_date = hr_api.g_eot
      and  pen.prtt_enrt_rslt_stat_cd is null
      and  pen.enrt_cvg_thru_dt = hr_api.g_eot
      and  pen.pl_id = pl.pl_id
      and  pl.imptd_incm_calc_cd = p_imptd_incm_calc_cd
      and  pl.pl_stat_cd = 'A'
      and  pen.enrt_cvg_strt_dt between pl.effective_start_date and pl.effective_end_date
      and  not exists (select 1
                         from ben_elig_per_elctbl_chc epe
                        where epe.pl_id  = pen.pl_id
                          and epe.pgm_id = pen.pgm_id
                          and epe.per_in_ler_id = p_per_in_ler_id);