The following lines contain the word 'select', 'insert', 'update' or 'delete':
SELECT asset_number
INTO g_asset_number
FROM fa_additions_b
where asset_id = g_asset_id;
SELECT asset_id
INTO l_asset_id
FROM fa_additions_b
WHERE asset_number = p_asset_number;
SELECT count(*)
INTO l_count
FROM fa_books
WHERE asset_id = g_asset_id
AND book_type_code = g_book;
select release_name
into l_app_version
from fnd_product_groups;
select count(1)
into l_check_reval
from fa_transaction_headers
where transaction_type_code = 'REVALUATION'
and asset_id = g_asset_id
and book_type_code = g_book;
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_cnt_stmt := 'SELECT count(1) FROM FA_TRANSACTION_HEADERS'
||' WHERE asset_id = '||g_asset_id||' and book_type_code in ('||''''||g_source_book||''''||','||''''||g_book||''''||')';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_cnt_stmt := 'SELECT count(1) FROM FA_DISTRIBUTION_HISTORY'
||' WHERE asset_id = '||g_asset_id||' and book_type_code = '||''''||g_source_book||'''';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
||' and mass_reval_id in (select mass_transaction_id from fa_transaction_headers where transaction_type_code = ''REVALUATION'''
||' and asset_id = '||g_asset_id||' and book_type_code = '||'''' || g_book || ''''||')';
l_options_tbl(l_idx).l_cnt_stmt := 'Select count(1) '||l_options_tbl(l_idx).l_add_clause;
l_options_tbl(l_idx).l_gen_select := 'Y';
||' and mass_reval_id in (select mass_transaction_id from fa_transaction_headers where transaction_type_code = ''REVALUATION'''
||' and asset_id = '||g_asset_id||' and book_type_code = '||'''' || g_book || ''''||')';
l_options_tbl(l_idx).l_cnt_stmt := 'Select count(1) '||l_options_tbl(l_idx).l_add_clause;
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_cnt_stmt := 'Select count(1) '||l_options_tbl(l_idx).l_add_clause;
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_cnt_stmt := 'SELECT count(it.invoice_transaction_id) FROM FA_INVOICE_TRANSACTIONS it, fa_asset_invoices ai'
||' where ai.asset_id = ' || g_asset_id ||' and (ai.invoice_transaction_id_in = it.invoice_transaction_id '
||' or ai.invoice_transaction_id_out = it.invoice_transaction_id)';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_cnt_stmt := 'SELECT count(1) FROM FA_TRX_REFERENCES WHERE book_type_code = '||''''||g_book||''''
||' and (member_asset_id = '||g_asset_id||' or src_asset_id = '||g_asset_id||' or dest_asset_id = '||g_asset_id||')';
l_options_tbl(l_idx).l_cnt_stmt := 'Select count(1) '||l_options_tbl(l_idx).l_add_clause;
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
g_options_tbl.delete;
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_cnt_stmt := 'SELECT count(*) FROM fa_mass_additions WHERE asset_number = '
||''''||g_asset_number||'''' ||' OR add_to_asset_id = '||g_asset_id;
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_add_clause := ' FROM FA_MASSADD_DISTRIBUTIONS WHERE mass_addition_id IN (SELECT mass_addition_id FROM '
||'fa_mass_additions WHERE asset_number =' ||''''||g_asset_number||''''||')';
l_options_tbl(l_idx).l_cnt_stmt := 'SELECT count(*) FROM fa_mass_additions WHERE asset_number = '
||''''||g_asset_number||'''' ||' OR add_to_asset_id = '||g_asset_id;
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_add_clause := ' FROM FA_MC_MASS_RATES WHERE mass_addition_id IN (SELECT mass_addition_id FROM fa_mass_additions '
||'WHERE asset_number =' ||''''||g_asset_number||''''||')';
l_options_tbl(l_idx).l_cnt_stmt := 'SELECT count(*) FROM fa_mass_additions WHERE asset_number = '
||''''||g_asset_number||'''' ||' OR add_to_asset_id = '||g_asset_id;
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_add_clause := ' FROM FA_CATEGORIES_B WHERE category_id IN (SELECT DISTINCT ah.category_id FROM fa_asset_history ah'
||' WHERE ah.asset_id = '||g_asset_id|| ') ORDER BY category_id';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_add_clause := ' FROM FA_CATEGORIES_TL WHERE category_id IN (SELECT DISTINCT ah.category_id FROM fa_asset_history ah'
||' WHERE ah.asset_id = '||g_asset_id|| ') ORDER BY category_id';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_add_clause := ' FROM fa_category_books WHERE category_id IN (SELECT DISTINCT ah.category_id FROM fa_asset_history ah'
||' WHERE ah.asset_id = '||g_asset_id|| ') AND book_type_code = '||''''||g_book||'''' ||' ORDER BY category_id';
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_add_clause := ' FROM fa_category_book_defaults WHERE category_id IN (SELECT DISTINCT ah.category_id '
||'FROM fa_asset_history ah WHERE ah.asset_id = '||g_asset_id||') AND book_type_code = '||''''||g_book||''''
||' ORDER BY category_id, start_dpis';
l_select_clause varchar2(2000);
SELECT APPLICATION_COLUMN_NAME, SEGMENT_NAME
from fnd_id_flex_segments
where application_id = 101
and id_flex_code = 'GL#'
AND ID_FLEX_NUM = l_flex_num;
l_select_clause := l_select_clause||','||l_dist_tbl(i);
l_select_clause := substr(l_select_clause,2,length(l_select_clause));
fa_debug_pkg.add(l_calling_fn, 'l_select_clause', l_select_clause,
p_log_level_rec => p_log_level_rec);
l_options_tbl(l_idx).l_gen_select := 'N';
l_options_tbl(l_idx).l_col_order := l_select_clause;
(SELECT '||l_tbl_cols(i).cCol||' from fa_category_books where book_type_code = '||''''||g_book||'''' ||
' and category_id in (SELECT DISTINCT ah.category_id FROM fa_asset_history ah
WHERE ah.asset_id = '||g_asset_id||')) ORDER BY code_combination_id';
l_stmt := 'select count(1) '||l_options_tbl(l_idx).l_add_clause;
(SELECT distinct code_combination_id from fa_adjustments where book_type_code = '||''''||g_book||''''||
' and asset_id = '||g_asset_id||' and code_combination_id is not null) ORDER BY code_combination_id';
l_stmt := 'select count(1) '||l_options_tbl(l_idx).l_add_clause;
(select distinct code_combination_id from XLA_AE_LINES where application_id = 140 and ae_header_id in
(select ae_header_id from xla_ae_headers where application_id = 140 and event_id '||get_event_list
||')) ORDER BY code_combination_id';
l_stmt := 'select count(1) '||l_options_tbl(l_idx).l_add_clause;
(SELECT code_combination_id FROM fa_distribution_history
WHERE asset_id = '||g_asset_id||' AND transaction_header_id_out IS NULL) ORDER BY code_combination_id';
l_stmt := 'select count(1) '||l_options_tbl(l_idx).l_add_clause;
(SELECT FLEXBUILDER_DEFAULTS_CCID FROM fa_book_controls WHERE book_type_code = '||''''||g_book||''''||')';
l_stmt := 'select count(1) '||l_options_tbl(l_idx).l_add_clause;
(SELECT '||l_tbl_cols(i).cCol||' from fa_distribution_accounts WHERE distribution_id IN
(SELECT distribution_id FROM fa_distribution_history WHERE asset_id = '||g_asset_id||'))
ORDER BY code_combination_id';
l_stmt := 'select count(1) '||l_options_tbl(l_idx).l_add_clause;
l_options_tbl.delete(l_idx);
l_dist_tbl.delete;
l_options_tbl(l_idx).l_gen_select := 'N';
||',SETS.SECURITY_ENABLED_FLAG,STRU.FREEZE_FLEX_DEFINITION_FLAG,STRU.DYNAMIC_INSERTS_ALLOWED_FLAG,STRU.CROSS_SEGMENT_VALIDATION_FLAG';
l_select_clause varchar2(4000);
l_options_tbl(l_idx).l_gen_select := 'N';
l_options_tbl(l_idx).l_gen_select := 'N';
' AND (CO.PRORATE_CONVENTION_CODE IN (select distinct PRORATE_CONVENTION_CODE from fa_books '||
' where asset_id = '||g_asset_id||' and book_type_code = '||'''' || g_book || ''''||') '||
' OR CO.PRORATE_CONVENTION_CODE in (select distinct RETIREMENT_PRORATE_CONVENTION from fa_retirements '||
' where asset_id = '||g_asset_id|| ' and book_type_code = '||'''' || g_book || ''''||')) '||
' AND CO.START_DATE BETWEEN FY.START_DATE AND FY.END_DATE '||
' AND CO.PRORATE_CONVENTION_CODE = CT.PRORATE_CONVENTION_CODE ORDER BY CT.PRORATE_CONVENTION_CODE, CO.START_DATE';
l_options_tbl(l_idx).l_gen_select := 'N';
' where BR.BONUS_RULE=BRL.BONUS_RULE and BR.BONUS_RULE IN (select distinct BONUS_RULE from fa_books '||
' where asset_id = '||g_asset_id||' and book_type_code = '||'''' || g_book || ''''||') '||
' order by BR.Bonus_Rule,BR.Start_Year';
l_options_tbl(l_idx).l_cnt_stmt := 'select count(1) '||l_options_tbl(l_idx).l_add_clause;
l_options_tbl(l_idx).l_gen_select := 'N';
||' WHERE cl.ceiling_name = ct.ceiling_name AND (cl.ceiling_name in (select distinct Ceiling_Name '||
' from fa_books where asset_id = '||g_asset_id||' and book_type_code = '||'''' || g_book || ''''||') '
||' OR cl.ceiling_name in (select Ceiling_Name from fa_category_book_defaults '||
' where category_id in (SELECT DISTINCT ah.category_id FROM fa_asset_history ah '||
' WHERE ah.asset_id = '||g_asset_id|| ') and book_type_code = '||'''' || g_book || ''''||'))';
l_options_tbl(l_idx).l_cnt_stmt := 'select count(1) '||l_options_tbl(l_idx).l_add_clause;
l_options_tbl(l_idx).l_gen_select := 'N';
l_options_tbl(l_idx).l_cnt_stmt := 'select count(1) '||l_options_tbl(l_idx).l_add_clause;
||' IN (select DEPRN_METHOD_CODE||to_char(nvl(LIFE_IN_MONTHS,99999)) from fa_books'
||' where book_type_code = '||'''' || g_book || ''''||' and asset_id = '||g_asset_id||')';
l_options_tbl(l_idx).l_add_clause := ' FROM fa_deprn_basis_rules WHERE deprn_basis_rule_id IN (SELECT deprn_basis_rule_id'
||' FROM fa_methods WHERE METHOD_CODE||to_char(nvl(LIFE_IN_MONTHS,99999)) IN '
||'(select DEPRN_METHOD_CODE||to_char(nvl(LIFE_IN_MONTHS,99999)) from fa_books where book_type_code = '
||'''' || g_book || ''''||' and asset_id = '||g_asset_id||'))';
l_options_tbl(l_idx).l_cnt_stmt := 'select count(1) '||l_options_tbl(l_idx).l_add_clause;
||'(SELECT to_char(mt.method_id) || to_char(basic_rate) FROM FA_METHODS mt, fa_books bk '
||'where mt.method_code = bk.deprn_method_code and nvl(mt.life_in_months,0) = nvl(bk.life_in_months,0) '
||'and bk.book_type_code = '||'''' || g_book || ''''||' and bk.asset_id = '||g_asset_id||')';
l_options_tbl(l_idx).l_cnt_stmt := 'select count(1) '||l_options_tbl(l_idx).l_add_clause;
l_options_tbl(l_idx).l_add_clause := ' From fa_formulas Where method_id in (SELECT mt.method_id '
||'FROM FA_METHODS mt, fa_books bk where mt.method_code = bk.deprn_method_code '
||'and nvl(mt.life_in_months,0) = nvl(bk.life_in_months,0) and bk.book_type_code = '||'''' || g_book || ''''
||' and bk.asset_id = '||g_asset_id||')';
l_options_tbl(l_idx).l_cnt_stmt := 'select count(1) '||l_options_tbl(l_idx).l_add_clause;
select ev.event_id, en.entity_code
from fa_transaction_headers th, xla_transaction_entities en, xla_events ev
where th.book_type_code = g_book
and th.asset_id = g_asset_id
and en.application_id = l_appid
and en.ledger_id = g_sob_id
and en.entity_code = 'TRANSACTIONS'
and nvl(en.source_id_int_1, (-99)) = th.transaction_header_id
and ev.application_id = l_appid
and ev.entity_id = en.entity_id
union
select ev.event_id, en.entity_code
from fa_transaction_headers th, xla_transaction_entities en, xla_events ev
where th.book_type_code = g_book
and th.asset_id = g_asset_id
and en.application_id = l_appid
and en.ledger_id = g_sob_id
and en.entity_code = 'INTER_ASSET_TRANSACTIONS'
and nvl(en.source_id_int_1, (-99)) = th.trx_reference_id
and ev.application_id = l_appid
and ev.entity_id = en.entity_id
union
select ev.event_id, en.entity_code
from xla_transaction_entities en, xla_events ev, fa_book_controls bc
where bc.book_type_code = g_book
and en.application_id = l_appid
and en.ledger_id = g_sob_id
and en.entity_code = 'DEPRECIATION'
and nvl(en.source_id_int_1, (-99)) = g_asset_id
and nvl(en.source_id_char_1, '') = bc.book_type_code
and ev.application_id = l_appid
and ev.entity_id = en.entity_id;
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_cnt_stmt := 'Select count(1) '||l_options_tbl(l_idx).l_add_clause;
l_options_tbl(l_idx).l_gen_select := 'Y';
||' and entity_id in (select entity_id from xla_events where event_id '||l_event_list||')';
l_options_tbl(l_idx).l_cnt_stmt := 'Select count(1) '||l_options_tbl(l_idx).l_add_clause;
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_cnt_stmt := 'Select count(1) '||l_options_tbl(l_idx).l_add_clause;
l_options_tbl(l_idx).l_cnt_stmt := 'Select count(1) '||l_options_tbl(l_idx).l_add_clause;
l_options_tbl(l_idx).l_gen_select := 'Y';
||' and ae_header_id in (select ae_header_id from xla_ae_headers where application_id = '||l_appid||' and event_id '||l_event_list||')';
l_options_tbl(l_idx).l_cnt_stmt := 'Select count(1) '||l_options_tbl(l_idx).l_add_clause;
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_cnt_stmt := 'Select count(1) '||l_options_tbl(l_idx).l_add_clause;
l_options_tbl(l_idx).l_gen_select := 'Y';
'(select SLA_ACCOUNTING_METHOD_CODE from gl_ledgers where ledger_id = '||g_sob_id||')';
l_options_tbl(l_idx).l_cnt_stmt := 'Select count(1) '||l_options_tbl(l_idx).l_add_clause;
l_options_tbl(l_idx).l_gen_select := 'Y';
'(select distinct product_rule_code from xla_ae_headers where application_id = '||l_appid||' and event_id '||l_event_list||')';
l_options_tbl(l_idx).l_cnt_stmt := 'Select count(1) '||l_options_tbl(l_idx).l_add_clause;
l_options_tbl(l_idx).l_gen_select := 'Y';
l_options_tbl(l_idx).l_add_clause := ' from xla_ledger_options where (ledger_id = '||g_sob_id||' or ledger_id in (select target_ledger_id '||
' FROM gl_ledger_relationships WHERE primary_ledger_id = '||g_sob_id||' AND relationship_type_code <> ''NONE'' '||
' AND application_id IN (101,140) AND relationship_enabled_flag = ''Y'')) and application_id IN (101,140) order by APPLICATION_ID, LEDGER_ID';
l_options_tbl(l_idx).l_cnt_stmt := 'Select count(1) '||l_options_tbl(l_idx).l_add_clause;
l_options_tbl(l_idx).l_gen_select := 'N';
l_options_tbl(l_idx).l_add_clause := ' from gl_ledgers where ledger_id = '||g_sob_id||' or ledger_id in (select target_ledger_id '||
' FROM gl_ledger_relationships WHERE primary_ledger_id = '||g_sob_id||' AND relationship_type_code <> ''NONE'' '||
' AND application_id IN (101,140) AND relationship_enabled_flag = ''Y'') order by ledger_id';
l_options_tbl(l_idx).l_cnt_stmt := 'Select count(1) '||l_options_tbl(l_idx).l_add_clause;
l_idx:= l_idx+ 1; l_col_exclusions(l_idx).cValue := 'LAST_UPDATE_LOGIN';
log('prt_opt_tbl',p_options_tbl(i).l_gen_select);