Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create procedure "arballon".com_creutl(i_cod_emp smallint, i_cod_amb smallint,
- i_tip_opr smallint, i_cod_opr char(16),
- i_cod_dis char(1), i_fch_cot date)
- returning decimal(18,2);
- define s_cre_utl decimal(18,2);
- define s_dif decimal(18,2);
- let s_cre_utl=0;
- let s_dif=0;
- let s_cre_utl = (select sum(gen_premdanac(b.dal_ope, a.cod_mda, i_fch_cot, a.tip_cot, a.cod_ind))
- --let s_cre_utl = (select sum(b.dal_ope)
- from anlsdo b, anlcod a, concta n
- where 1=1
- and b.cod_emp = i_cod_emp
- and b.cod_amb = i_cod_amb
- and b.tip_opr = i_tip_opr
- and b.cta_anl = i_cod_opr
- and b.tip_mov = '='
- and a.cod_emp = b.cod_emp
- and a.cod_amb = b.cod_amb
- and a.cod_anl = b.cod_anl
- --and a.flg_cre != 'N'
- and (i_cod_dis = ' ' or a.flg_anl = i_cod_dis)
- and n.cod_emp = a.cod_emp
- and n.cod_amb = a.cod_amb
- and n.cod_cta = a.cod_cta
- and n.tip_res != 'S'
- );
- if s_cre_utl is null then let s_cre_utl=0; end if;
- let s_dif = (select sum(gen_premdanac(a.pen_ope, c.cod_mda, i_fch_cot, c.tip_cot, c.cod_ind))
- --let s_dif = (select sum(a.pen_ope)
- from anlopepen a, anltxt b, anlcod c
- where 1=1
- and a.cod_emp = i_cod_emp
- and a.cod_amb = i_cod_amb
- and a.tip_opr = i_tip_opr
- and a.cta_anl = i_cod_opr
- and a.tip_mov = '+'
- and a.pen_ope != 0
- and b.cod_emp = a.cod_emp
- and b.cod_amb = a.cod_amb
- and b.cod_ope = a.cod_ope
- and b.cen_ope = a.cen_ope
- and b.nro_ope = a.nro_ope
- and b.cod_anl = a.cod_anl
- and b.cta_anl = a.cta_anl
- and b.vto_ope = a.fch_vto
- and b.cod_edo = 20
- and b.cod_ref IN('OP.TV','REC.TV')
- and c.cod_emp = a.cod_emp
- and c.cod_amb = a.cod_amb
- and c.cod_anl = a.cod_anl
- and (i_cod_dis = ' ' or c.flg_anl = i_cod_dis)
- );
- if s_dif is null then let s_dif=0; end if;
- return (s_cre_utl - s_dif);
- end procedure;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement