Está en la página 1de 7

PROCEDUREp_CARGAR_SPTOS_9(p_origen varchar2) IS

c_fecha date;

BEGIN

begin

executeimmediate'truncate table
bdimut.S86_HEC_MOD_CON_CIER_ries_d';

executeimmediate'truncate table bdimut.sptos_9';

insert/*+ parallel */intobdimut.sptos_9

select/*+ parallel(a,4)
*/a.num_contr_nivel1,a.num_contr_nivel2,a.num_contr_nivel3,a.num_spto,a.num_sp
to_modif,a.num_Spto_publico,a.cod_situacion,

max(casewhena.num_spto>20000then/*nvl(b.num_Spto,0)*/0elsea.num_spto end)
num_spto_b,

/*a.sk_fec_imput,*/

to_number(casewhena.fec_efecto_modif
isnullora.fec_cierre>= a.fec_efecto_modif
thento_char(a.fec_cierre,'yyyymmdd')

elseto_char(a.fec_efecto_modif,'yyyymmdd') end)
sk_fec_imput,

casewhena.cod_situacion='AN'thennvl(a.fec_anulacion,a.fec_efecto_modif)
elsenullendfec_anulacion,a.mca_innom,

a.fec_vencimiento,a.cod_origen,a.fec_cierre,

nvl(a.fec_cierre,a.fec_efecto_modif)
fec_efecto_modif,

a.cod_entidad,a.cod_clave_prod,a.cod_forma_pago,a.cod_forma_cobro,a.cod_oficin
a,a.cod_motivo_anul,

min(c.fec_emision) fec_emision,

a.cod_ramo,

max(a.fec_ult_renov) fec_ult_renov,

MAX(a.NUM_ASEGURADOS) NUM_ASEGURADOS,

min(fec_efecto) fec_Efecto,

min(a.cod_periodo_emi) cod_periodo_emi,

a.tip_spto
frombdimut.s86_hec_mod_con_IFR_his
a,/*bdimut.s86_hec_mod_con_IFR_his b,*/bdimut.s86_hec_contrat_ifr_his c

where /*b.num_spto(+)<20000

and a.num_contr_nivel1=b.num_contr_nivel1(+)

and a.num_contr_nivel2=b.num_contr_nivel2(+)

and a.num_contr_nivel3=b.num_contr_nivel3(+)

and*/a.num_contr_nivel1=c.num_contr_nivel1

anda.num_contr_nivel2=c.num_contr_nivel2

anda.num_contr_nivel3=c.num_contr_nivel3

/* and a.sk_fec_imput>=b.sk_fec_imput(+)*/

anda.cod_origen='9'

/* and b.cod_origen(+)='9'*/

andc.cod_origen='9'

group by
a.num_contr_nivel1,a.num_contr_nivel2,a.num_contr_nivel3,a.num_spto,a.num_spto
_modif,a.num_Spto_publico,

to_number(casewhena.fec_efecto_modif
isnullora.fec_cierre>= a.fec_efecto_modif
thento_char(a.fec_cierre,'yyyymmdd')

elseto_char(a.fec_efecto_modif,'yyyymmdd') end),

a.cod_situacion,

casewhena.cod_situacion='AN'thennvl(a.fec_anulacion,a.fec_efecto_modif)
elsenullend,a.mca_innom,

a.fec_vencimiento,a.cod_origen,nvl(a.fec_cierre,a.fec_efecto_modif),a.fec_cier
re,

a.cod_entidad,a.cod_clave_prod,a.cod_forma_pago,a.cod_forma_cobro,a.cod_oficin
a,a.cod_motivo_anul,a.cod_ramo,

a.tip_spto

commit;

insert/*+ parallel */intobdimut.sptos_9

select/*+ parallel(a,4)
*/a.num_contr_nivel1,a.num_contr_nivel2,a.num_contr_nivel3,a.num_spto,a.num_sp
to_modif,a.num_Spto_publico,a.cod_situacion,

max(casewhena.num_spto>20000then/*nvl(b.num_Spto,0)*/0elsea.num_spto end)
num_spto_b,

/*a.sk_fec_imput,*/

to_number(casewhena.fec_efecto_modif
isnullora.fec_cierre>= a.fec_efecto_modif
thento_char(a.fec_cierre,'yyyymmdd')

elseto_char(a.fec_efecto_modif,'yyyymmdd') end)
sk_fec_imput,

casewhena.cod_situacion='AN'thennvl(a.fec_anulacion,a.fec_efecto_modif)
elsenullendfec_anulacion,a.mca_innom,

a.fec_vencimiento,a.cod_origen,a.fec_cierre,

nvl(a.fec_cierre,a.fec_efecto_modif)
fec_efecto_modif,

a.cod_entidad,a.cod_clave_prod,a.cod_forma_pago,a.cod_forma_cobro,a.cod_oficin
a,a.cod_motivo_anul,

min(c.fec_emision) fec_emision,

a.cod_ramo,

max(a.fec_ult_renov) fec_ult_renov,

MAX(a.NUM_ASEGURADOS) NUM_ASEGURADOS,

min(fec_efecto) fec_Efecto,

min(a.cod_periodo_emi) cod_periodo_emi,

a.tip_spto

fromdss_ld.s86_hec_mod_con
a,/*bdimut.s86_hec_mod_con_IFR_his b,*/dss_ld.s86_hec_contrat c

where /*b.num_spto(+)<20000

and a.num_contr_nivel1=b.num_contr_nivel1(+)

and a.num_contr_nivel2=b.num_contr_nivel2(+)

and a.num_contr_nivel3=b.num_contr_nivel3(+)

and*/a.num_contr_nivel1=c.num_contr_nivel1

anda.num_contr_nivel2=c.num_contr_nivel2

anda.num_contr_nivel3=c.num_contr_nivel3

/* and a.sk_fec_imput>=b.sk_fec_imput(+)*/
anda.cod_origen='9'

/* and b.cod_origen(+)='9'*/

andc.cod_origen='9'

group by
a.num_contr_nivel1,a.num_contr_nivel2,a.num_contr_nivel3,a.num_spto,a.num_spto
_modif,a.num_Spto_publico,

to_number(casewhena.fec_efecto_modif
isnullora.fec_cierre>= a.fec_efecto_modif
thento_char(a.fec_cierre,'yyyymmdd')

elseto_char(a.fec_efecto_modif,'yyyymmdd') end),

a.cod_situacion,

casewhena.cod_situacion='AN'thennvl(a.fec_anulacion,a.fec_efecto_modif)
elsenullend,a.mca_innom,

a.fec_vencimiento,a.cod_origen,nvl(a.fec_cierre,a.fec_efecto_modif),a.fec_cier
re,

a.cod_entidad,a.cod_clave_prod,a.cod_forma_pago,a.cod_forma_cobro,a.cod_oficin
a,a.cod_motivo_anul,a.cod_ramo,

a.tip_spto

commit;

insert/*+ parallel */intobdimut.S86_HEC_MOD_CON_CIER_ries_d

num_contr_nivel1,

num_contr_nivel2,

num_contr_nivel3,

num_spto,

num_spto_modif,

num_spto_publico,

num_spto_admin,

num_spto_real,

fec_alta,

fec_actu,
cod_usr,

cod_origen,

cod_situacion,

sk_fec_imput,

fec_anulacion,

mca_innm,

fec_vencimiento,

fec_efecto_modif,

cod_entidad,

cod_clave_prod,

cod_forma_pago,

cod_forma_cobro,

cod_oficina,

cod_motivo_anul,

fec_emision,

cod_ramo,

NUM_ASEGURADOS,

fec_efecto,

cod_periodo_emi,

tip_spto,

fec_ult_renov

select/*+ parallel(a,4) */
num_contr_nivel1,num_contr_nivel2,num_contr_nivel3,num_spto,num_spto_modif,num
_Spto_publico,num_spto_b,

ROW_NUMBER()
OVER(PARTITIONBYnum_contr_nivel1,num_contr_nivel2, num_contr_nivel3

order
byfec_efecto_modif,num_Spto_publico,num_spto_b,num_spto_modif)-
1rn,trunc(fec_cierre)
fec_alta,sysdatefec_actu,'BI_ETL'cod_usr,cod_origen ,cod_situacion,

/*sk_fec_imput,*/

casewhencod_periodo_emi isnullorsk_fec_imput>=
nvl(cod_periodo_emi,substr(sk_fec_imput,1,6))||'01' thensk_fec_imput
elseto_number(nvl(cod_periodo_emi,substr(sk_fec_imput,1,6))||'01')
endsk_fec_imput,

fec_anulacion,mca_innom,

fec_vencimiento,fec_efecto_modif,cod_entidad,cod_clave_prod,cod_forma_pago,cod
_forma_cobro,cod_oficina,cod_motivo_anul,fec_emision,

cod_ramo,

NUM_ASEGURADOS,

fec_efecto,

cod_periodo_emi,

tip_spto,

fec_ult_renov

from(bdimut.sptos_9 ) a;

commit;

EXCEPTION

WHENOTHERS THEN

RAISE;

END;

ENDp_CARGAR_SPTOS_9;
--

ROLANDO
HERNANDE
Z
CASTILLO
Operación Nivel
1
World Software
Services S.A.

También podría gustarte