Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. create procedure "arballon".com_creutl(i_cod_emp smallint, i_cod_amb smallint,
  2. i_tip_opr smallint, i_cod_opr char(16),
  3. i_cod_dis char(1), i_fch_cot date)
  4. returning decimal(18,2);
  5.  
  6. define s_cre_utl decimal(18,2);
  7. define s_dif decimal(18,2);
  8. let s_cre_utl=0;
  9. let s_dif=0;
  10.  
  11. let s_cre_utl = (select sum(gen_premdanac(b.dal_ope, a.cod_mda, i_fch_cot, a.tip_cot, a.cod_ind))
  12. --let s_cre_utl = (select sum(b.dal_ope)
  13. from anlsdo b, anlcod a, concta n
  14. where 1=1
  15. and b.cod_emp = i_cod_emp
  16. and b.cod_amb = i_cod_amb
  17. and b.tip_opr = i_tip_opr
  18. and b.cta_anl = i_cod_opr
  19. and b.tip_mov = '='
  20.  
  21. and a.cod_emp = b.cod_emp
  22. and a.cod_amb = b.cod_amb
  23. and a.cod_anl = b.cod_anl
  24. --and a.flg_cre != 'N'
  25. and (i_cod_dis = ' ' or a.flg_anl = i_cod_dis)
  26.  
  27. and n.cod_emp = a.cod_emp
  28. and n.cod_amb = a.cod_amb
  29. and n.cod_cta = a.cod_cta
  30. and n.tip_res != 'S'
  31. );
  32. if s_cre_utl is null then let s_cre_utl=0; end if;
  33.  
  34. let s_dif = (select sum(gen_premdanac(a.pen_ope, c.cod_mda, i_fch_cot, c.tip_cot, c.cod_ind))
  35. --let s_dif = (select sum(a.pen_ope)
  36. from anlopepen a, anltxt b, anlcod c
  37. where 1=1
  38. and a.cod_emp = i_cod_emp
  39. and a.cod_amb = i_cod_amb
  40. and a.tip_opr = i_tip_opr
  41. and a.cta_anl = i_cod_opr
  42. and a.tip_mov = '+'
  43. and a.pen_ope != 0
  44.  
  45. and b.cod_emp = a.cod_emp
  46. and b.cod_amb = a.cod_amb
  47. and b.cod_ope = a.cod_ope
  48. and b.cen_ope = a.cen_ope
  49. and b.nro_ope = a.nro_ope
  50. and b.cod_anl = a.cod_anl
  51. and b.cta_anl = a.cta_anl
  52. and b.vto_ope = a.fch_vto
  53. and b.cod_edo = 20
  54. and b.cod_ref IN('OP.TV','REC.TV')
  55.  
  56. and c.cod_emp = a.cod_emp
  57. and c.cod_amb = a.cod_amb
  58. and c.cod_anl = a.cod_anl
  59. and (i_cod_dis = ' ' or c.flg_anl = i_cod_dis)
  60. );
  61.  
  62. if s_dif is null then let s_dif=0; end if;
  63.  
  64. return (s_cre_utl - s_dif);
  65.  
  66. end procedure;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement