You are on page 1of 1

Cursor Query in function glpks_avgbal

cursor cursor_old_txns(pglopt varchar2,


pcyopt varchar2,
p_glcode varchar2,
pccy_code varchar2) is
select a.brn,
a.acc,
a.ccy,
a.val_dt,
decode(a.ccy, global.lcy, a.bal, a.lcy_bal) lcy_bal,
a.bal acy_bal,
decode(a.ccy, global.lcy, a.bal, a.lcy_bal) ytodlcy_bal,
a.bal ytodacy_bal
from actb_vd_bal a
where a.brn = pbranch
and a.acc = decode(pglopt, 'A', a.acc, 'S', p_glcode)
and a.ccy = decode(pcyopt, 'A', a.ccy, 'S', pccy_code)
and (a.brn, a.acc, a.ccy, a.val_dt) in
(select b.brn, b.acc, b.ccy, max(b.val_dt) valdt
from actb_vd_bal b
--FCC 5.2 - 9i changes - Moved the group by and having clauses to
the end of the select
--group by brn, acc, ccy
--having max(val_dt) < pfrom_period
where a.brn = b.brn
and a.acc = b.acc
and a.ccy = b.ccy
group by brn, acc, ccy
having max(val_dt) < pfrom_period)
order by a.brn, a.acc, a.ccy;

You might also like