The following lines contain the word 'select', 'insert', 'update' or 'delete':
select distinct valuation_method,
ENTITY_CODE,
EVENT_TYPE_CODE
from xla_events_gt;
update fa_book_controls
set create_accounting_request_id = fnd_global.conc_request_id
where book_type_code = p_book_type_code;
update fa_book_controls
set create_accounting_request_id = null
where book_type_code = p_book_type_code;
PROCEDURE update_nonaccountable_events
(p_book_type_code varchar2,
p_process_category varchar2) IS
l_appl_id number := 140;
l_procedure_name varchar2(80) := 'update_nonaccountable_events';
select 1
into l_trx
from dual
where exists(
select 1
from xla_event_class_attrs
where application_id = 140
and entity_code in ('TRANSACTIONS', 'INTER_ASSET_TRANSACTIONS')
and EVENT_CLASS_GROUP_CODE = nvl(p_process_category,
EVENT_CLASS_GROUP_CODE));
insert into xla_events_int_gt
(event_id,
event_status_code,
application_id,
ledger_id,
entity_code,
valuation_method)
select /*+ leading(EV,TE) use_nl(EV TE TH BC) */
ev.event_id,
'N',
140,
bc.set_of_books_id,
'TRANSACTIONS',
bc.book_type_code
from xla_transaction_entities te,
xla_events ev,
fa_transaction_headers th,
fa_book_controls bc
where te.application_id = l_appl_id
and te.ledger_id = bc.set_of_books_id
and te.entity_code = 'TRANSACTIONS'
and te.valuation_method = p_book_type_code
and ev.application_id = l_appl_id
and ev.process_status_code <> 'P'
and ev.entity_id = te.entity_id
and ev.request_id = fnd_global.conc_request_id --bug# 7642903
and ev.event_type_code in
('ADDITIONS',
'ADJUSTMENTS',
'CAPITALIZATION',
'REVERSE_CAPITALIZATION',
'CATEGORY_RECLASS',
'CIP_ADDITIONS',
'CIP_ADJUSTMENTS',
'CIP_CATEGORY_RECLASS',
'CIP_REINSTATEMENTS',
'CIP_RETIREMENTS',
'CIP_REVALUATION',
'CIP_TRANSFERS',
'CIP_UNIT_ADJUSTMENTS',
'DEPRECIATION_ADJUSTMENTS',
'REINSTATEMENTS',
'RETIREMENTS',
'RETIREMENT_ADJUSTMENTS',
'REVALUATION',
'ROLLBACK_TERMINAL_GAIN_LOSS',
'TERMINAL_GAIN_LOSS',
'TRANSFERS',
'UNIT_ADJUSTMENTS',
'UNPLANNED_DEPRECIATION')
and th.transaction_header_id = te.source_id_int_1
and bc.book_type_code = p_book_type_code
and not exists
(select /*+ no_unnest */ 1
from fa_adjustments adj
where adj.transaction_header_id = th.transaction_header_id
and adj.book_type_code = bc.book_type_code
and adj.adjustment_amount <> 0
and nvl(adj.track_member_flag, 'N') <> 'Y')
and not exists
(select /*+ no_unnest index(adj FA_ADJUSTMENTS_U1) */ 1
from fa_adjustments adj,
fa_transaction_headers th2
where th2.member_transaction_header_id = th.transaction_header_id
and adj.transaction_header_id = th2.transaction_header_id
and adj.book_type_code = bc.book_type_code
and adj.adjustment_amount <> 0
and nvl(adj.track_member_flag, 'N') <> 'Y');
'Rows inserted into gt for non-accountable - trx: ' || to_char(l_trx_count));
insert into xla_events_int_gt
(event_id,
event_status_code,
application_id,
ledger_id,
entity_code,
valuation_method)
select /*+ leading(EV,TE) use_nl(EV TE TRX BC) */
ev.event_id,
'N',
140,
bc.set_of_books_id,
'INTER_ASSET_TRANSACTIONS',
bc.book_type_code
from xla_events ev,
xla_transaction_entities te,
fa_trx_references trx,
fa_book_controls bc
where te.application_id = l_appl_id
and te.ledger_id = bc.set_of_books_id
and te.entity_code = 'INTER_ASSET_TRANSACTIONS'
and te.valuation_method = p_book_type_code
and ev.application_id = l_appl_id
and ev.process_status_code <> 'P'
and ev.entity_id = te.entity_id
and ev.request_id = fnd_global.conc_request_id --bug# 7642903
and ev.event_type_code in
('CIP_SOURCE_LINE_TRANSFERS',
'SOURCE_LINE_TRANSFERS',
'RESERVE_TRANSFERS')
and trx.trx_reference_id = te.source_id_int_1
and bc.book_type_code = p_book_type_code
and not exists
(select /*+ no_unnest */ 1
from fa_adjustments adj
where adj.transaction_header_id in
(trx.src_transaction_header_id, trx.dest_transaction_header_id)
and adj.book_type_code = bc.book_type_code
and adj.adjustment_amount <> 0
and nvl(adj.track_member_flag, 'N') <> 'Y')
and not exists
(select /*+ no_unnest index(adj FA_ADJUSTMENTS_U1) */ 1
from fa_adjustments adj,
fa_transaction_headers th2
where th2.member_transaction_header_id in
(trx.src_transaction_header_id, trx.dest_transaction_header_id)
and adj.transaction_header_id = th2.transaction_header_id
and adj.book_type_code = bc.book_type_code
and adj.adjustment_amount <> 0
and nvl(adj.track_member_flag, 'N') <> 'Y');
'Rows inserted into gt for non-accountable - intertrx: ' || to_char(l_inter_trx_count));
'calling: ' || 'xla_events_pub_pkg.update_bulk_event_statuses');
xla_events_pub_pkg.update_bulk_event_statuses(p_application_id => 140);
END update_nonaccountable_events;