The following lines contain the word 'select', 'insert', 'update' or 'delete':
SELECT jle.code_combination_id,
gir.rowid,
gir.reference_1,
xla_gl_sl_link_id_s.nextval
FROM gl_je_headers gh,
gl_import_references gir,
gl_je_lines jle
WHERE gh.je_batch_id = p_je_batch_id
AND gh.je_header_id = jle.je_header_id
AND gir.je_header_id = jle.je_header_id
AND gir.je_line_num = jle.je_line_num
AND gir.gl_sl_link_table = 'MTA'
AND gir.gl_sl_link_id IS NULL;
SELECT l.rowid,
m.gl_sl_link_id
FROM mtl_transaction_accounts m,
cst_lists_temp c,
xla_distribution_links lk,
xla_ae_lines l
WHERE lk.application_id = 707
AND lk.source_distribution_type = 'MTL_TRANSACTION_ACCOUNTS'
AND lk.source_distribution_id_num_1 = c.number_1
AND lk.application_id = 707
AND lk.ae_header_id = l.ae_header_id
AND lk.ae_line_num = l.ae_line_num
AND l.application_id = 707
AND m.transaction_id = c.number_2
AND m.inv_sub_ledger_id = c.number_1
AND m.reference_account = c.number_3;
SELECT NULL
FROM cst_lists_temp
WHERE number_1 IS NULL
AND list_id = 999;
debug(' Update GIR.GL_SL_LINK_ID for MTA');
UPDATE gl_import_references
SET gl_sl_link_id = gl_sl_link_id_tab(i)
WHERE rowid = gir_rowid_tab(i);
debug(' Update MTA.GL_SL_LINK_ID for MTA');
UPDATE mtl_transaction_accounts
SET gl_sl_link_id = gl_sl_link_id_tab(i)
WHERE gl_batch_id = gl_batch_id_tab(i)
AND reference_account = ccid_tab(i);
debug(' Insert Cst_Lists_Temp for MTA');
INSERT INTO cst_lists_temp
(list_id ,
number_1,
number_2,
number_3,
varchar_1)
SELECT 999,
inv_sub_ledger_id,
transaction_id,
reference_account,
NULL
FROM mtl_transaction_accounts
WHERE gl_batch_id = gl_batch_id_tab(i)
AND reference_account = ccid_tab(i);
debug(' Update XAL.GL_SL_LINK_ID for MTA');
UPDATE xla_ae_lines
SET gl_sl_link_id = xl_link_id_tab(i)
WHERE rowid = xline_rowid_tab(i);
DELETE FROM cst_lists_temp;
SELECT jle.code_combination_id,
gir.rowid,
gir.reference_1,
xla_gl_sl_link_id_s.nextval
FROM gl_je_headers gh,
gl_import_references gir,
gl_je_lines jle
WHERE gh.je_batch_id = p_je_batch_id
AND gh.je_header_id = jle.je_header_id
AND gir.je_header_id = jle.je_header_id
AND gir.je_line_num = jle.je_line_num
AND gir.gl_sl_link_table = 'WTA'
AND gir.gl_sl_link_id IS NULL;
SELECT l.rowid,
m.gl_sl_link_id
FROM wip_transaction_accounts m,
cst_lists_temp c,
xla_distribution_links lk,
xla_ae_lines l
WHERE lk.application_id = 707
AND lk.source_distribution_type = 'WIP_TRANSACTION_ACCOUNTS'
AND lk.source_distribution_id_num_1 = c.number_1
AND lk.application_id = 707
AND lk.ae_header_id = l.ae_header_id
AND lk.ae_line_num = l.ae_line_num
AND l.application_id = 707
AND m.transaction_id = c.number_2
AND m.wip_sub_ledger_id = c.number_1
AND m.reference_account = c.number_3;
SELECT NULL
FROM cst_lists_temp
WHERE number_1 IS NULL
AND list_id = 999;
debug(' Update GIR.GL_SL_LINK_ID for WTA');
UPDATE gl_import_references
SET gl_sl_link_id = gl_sl_link_id_tab(i)
WHERE rowid = gir_rowid_tab(i);
debug(' Update WTA.GL_SL_LINK_ID for WTA');
UPDATE wip_transaction_accounts
SET gl_sl_link_id = gl_sl_link_id_tab(i)
WHERE gl_batch_id = gl_batch_id_tab(i)
AND reference_account = ccid_tab(i);
debug(' Insert Cst_Lists_Temp for WTA');
INSERT INTO cst_lists_temp
(list_id ,
number_1,
number_2,
number_3,
varchar_1)
SELECT 999,
wip_sub_ledger_id,
transaction_id,
reference_account,
NULL
FROM wip_transaction_accounts
WHERE gl_batch_id = gl_batch_id_tab(i)
AND reference_account = ccid_tab(i);
debug(' Insert XAL.GL_SL_LINK_ID for WTA');
UPDATE xla_ae_lines
SET gl_sl_link_id = xl_link_id_tab(i)
WHERE rowid = xline_rowid_tab(i);
DELETE FROM cst_lists_temp;
PROCEDURE update_mta_wta
(errbuf OUT NOCOPY VARCHAR2,
retcode OUT NOCOPY NUMBER,
p_from_date IN VARCHAR2,
p_to_date IN VARCHAR2,
p_ledger_id IN NUMBER)
IS
CURSOR c_glb(l_from_date IN DATE, l_to_date IN DATE)
IS
select a.je_batch_id
from gl_je_batches a,
gl_period_statuses b
where a.set_of_books_id_11i = b.set_of_books_id
and b.set_of_books_id = p_ledger_id
and a.default_effective_date >= l_from_date
and a.default_effective_date <= l_to_date
and b.migration_status_code = 'U'
and b.application_id = 401
and a.name like '%Inventory%';
debug('update_mta_wta +');
debug('update_mta_wta -');
debug('EXCEPTION OTHERS update_mta_wta :'||SQLERRM);
END update_mta_wta;