The following lines contain the word 'select', 'insert', 'update' or 'delete':
SELECT DISTINCT fth.transaction_header_id,
fa.asset_number,
greatest(greatest(fdp.calendar_period_open_date,
least(sysdate,
fdp.calendar_period_close_date)),
fdp.calendar_period_open_date) transaction_date,
fa.tag_number
FROM fa_retirements fr,
fa_transaction_headers fth,
fa_additions fa,
fa_books fb,
fa_book_controls_sec fbcs,
fa_distribution_history fdh,
fa_deprn_periods fdp
--gl_code_combinations gcc
WHERE (fth.transaction_type_code = 'FULL RETIREMENT' OR
fth.transaction_type_code = 'PARTIAL RETIREMENT')
AND fth.asset_id = fa.asset_id
AND fr.asset_id = fth.asset_id
AND fdh.asset_id = fa.asset_id
AND fb.asset_id = fa.asset_id
AND fb.transaction_header_id_out = fr.transaction_header_id_in
AND fa.asset_type = 'CAPITALIZED'
AND fth.book_type_code = fbcs.book_type_code
AND (fbcs.book_class = 'CORPORATE' or fbcs.book_class = 'TAX')
AND fbcs.gl_posting_allowed_flag = 'YES'
--AND fdh.book_type_code = fbcs.book_type_code -- remove this condition, fdh share book_type_code
AND fth.book_type_code = fdp.book_type_code
AND fdh.book_type_code = fdp.book_type_code
--AND fdh.code_combination_id = gcc.code_combination_id
AND fth.date_effective between fdp.period_open_date and
nvl(fdp.period_close_date, sysdate)
AND fdh.date_effective < nvl(fdp.period_close_date, sysdate)
AND (fdh.date_ineffective > fdp.period_open_date or
fdh.date_ineffective IS NULL)
--AND gcc.segment1 IN (SELECT segment_value
-- FROM gl_ledger_norm_seg_vals
-- WHERE legal_entity_id = ln_legal_entity_id
-- AND ledger_id = ln_ledger_id)
AND EXISTS
(SELECT jclllbg.bal_seg_value
FROM ja_cn_ledger_le_bsv_gt jclllbg
WHERE JA_CN_CFS_DATA_CLT_PKG.get_balancing_segment(fdh.code_combination_id) =
jclllbg.bal_seg_value
AND jclllbg.Ledger_Id = ln_ledger_id
AND jclllbg.Legal_Entity_Id = ln_legal_entity_id)
AND fbcs.set_of_books_id = ln_ledger_id
AND greatest(greatest(fdp.calendar_period_open_date,
least(sysdate,
fdp.calendar_period_close_date))) BETWEEN
ld_date_from AND ld_date_to
ORDER BY transaction_date, fth.transaction_header_id;
SELECT start_date
INTO ld_start_date
FROM GL_PERIOD_STATUSES
WHERE ledger_id = pn_ledger_id
AND application_id = 101
AND period_name = pv_period_from
AND period_year = pv_accounting_year;
SELECT end_date
INTO ld_end_date
FROM GL_PERIOD_STATUSES
WHERE ledger_id = pn_ledger_id
AND application_id = 101
AND period_name = pv_period_to
AND period_year = pv_accounting_year;
SELECT period_num
INTO lv_period_name
FROM gl_period_statuses gp
WHERE period_year = pv_accounting_year
AND application_id = 101
AND ledger_id = pn_ledger_id
AND gp.adjustment_period_flag = 'N'
AND v_row.Transaction_Date between gp.start_date and
gp.end_date;