forms (32bit) 10.1.2.0.2
pl/sql version 10.1.0.4.2
select cbd.borrow_id
,cbd.effective_date
,case
when count(rownum) over(partition by cbd.borrow_id order by cbd.borrow_id, cbd.effective_date) = 1 then cbd.effective_date
else cbd.effective_date + 1
end as bor_start_date
,nvl(lead(cbd.effective_date) over(partition by cbd.borrow_id order by cbd.borrow_id, cbd.effective_date)
,to_date(’2009-11’||’-01’,’yyyy-mm-dd’)-1) as bor_end_date
,cbd.amount
,sum(cbd.amount) over(partition by cbd.borrow_id order by cbd.borrow_id, cbd.effective_date) as tot_amount
,count(rownum) over(partition by cbd.borrow_id order by cbd.borrow_id, cbd.effective_date) as row_count
,decode(tbm.int_exp_cap_dept,’Z00000’,’일반차입금’,’C10201’,’일반차입금’,’특정차입금’) as bor_type
,to_date(ffv.attribute44,’yyyy-mm-dd’) as attribute44
,cbd.ledger_id
from cbogl_cap_bor_detail_trxs cbd
,xxtrf_borrow_masters tbm
,fnd_flex_values ffv
where cbd.borrow_id = tbm.borrow_id
and ffv.flex_value = tbm.int_exp_cap_dept
and ffv.flex_value_set_id = 1013516
and ffv.enabled_flag = ’Y’
and ffv.summary_flag = ’N’
and cbd.ledger_id = 2021 --G_SOB_ID
and cbd.rep_period_name = ’2009-11’ --parameter
and (
(tbm.int_exp_cap_dept in (’Z00000’,’C10201’) --일반차입금 일때
and tbm.int_exp_cap_flag = ’Y’ --자본화 대상일것
)
or (tbm.int_exp_cap_dept not in (’Z00000’,’C10201’) --특정차입금 일때
and ffv.attribute41 = ’Y’ --적격자산일것
)
)
and (cbd.status is null --오류 통제
or cbd.status <> ’E’)
and cbd.effective_date <= last_day(to_date(’2009-11’||’-01’,’yyyy-mm-dd’)) --회계년월의 말일
and cbd.bor_transaction_type in (’10’,’20’) --10:원금입금/20:원금상환
and not exists (select ’not 당자차월’ --당좌차월이 아닐것
from xxtrf_code_master tcm
,xxtrf_code_values tcv
where tcm.code = tcv.code
and tcm.code = ’BORROW_GROUP’
and tcv.value_name like ’%당좌%차월%’
and tcv.code_value = tbm.borrow_group
)
forms 는 over 함수 못쓰는건가요?
loop로 해결해야되나요?