The following lines contain the word 'select', 'insert', 'update' or 'delete':
PROCEDURE insert_trx (
procedure_name cn_obj_procedures_v.name%TYPE,
x_module_id cn_modules.module_id%TYPE,
x_event_id cn_events.event_id%TYPE,
code IN OUT NOCOPY cn_utils.code_type,
x_org_id IN NUMBER) IS
x_module_type cn_modules.module_type%TYPE;
SELECT LOWER(destcol.name) dest_column,
cm.expression expression
FROM cn_table_maps tm,
cn_column_maps cm,
cn_objects destcol
WHERE tm.mapping_type = 'INV1'
AND cm.table_map_id = tm.table_map_id
AND cm.expression IS NOT NULL
AND cm.destination_column_id = destcol.object_id
AND lower(destcol.NAME) <> 'sold_to_customer_id'
-- Added Last Where Clause For Bug Fix 3681852 Hithanki
-- Added for MOAC by Ashley
AND tm.org_id = x_org_id
AND cm.org_id = tm.org_id
AND destcol.org_id = cm.org_id
ORDER BY destcol.name;
cn_utils.appendcr(code, '--******** INSERT CN_TRX ********-- ');
cn_debug.print_msg('insert_trx>>', 1);
fnd_file.put_line(fnd_file.Log, 'insert_trx>>');
SELECT module_type --AE 11-16-95
INTO x_module_type
FROM cn_modules
WHERE module_id = x_module_id
--Added for MOAC by Ashley
AND org_id = x_org_id;
cn_debug.print_msg('insert_trx: x_module_id = ' || x_module_id, 1);
cn_debug.print_msg('insert_trx: Generating INSERT statement. ', 1);
fnd_file.put_line(fnd_file.Log, 'insert_trx: Generating INSERT statement. ');
cn_utils.appindcr(code, 'cn_message_pkg.debug('''|| procedure_name || ': Inserting into CN_TRX.'');');
cn_utils.appindcr(code, 'fnd_file.put_line(fnd_file.Log, '''|| procedure_name || ': Inserting into CN_TRX.'');');
cn_utils.appindcr(code, 'INSERT INTO cn_trx(');
cn_utils.appindcr(code, 'SELECT');
cn_utils.appindcr(code, ' SELECT trx_id');
cn_utils.appindcr(code, ' SELECT trx_id');
cn_utils.appindcr(code, 'INSERT INTO cn_trx(');
cn_utils.appindcr(code, 'SELECT');
cn_utils.appindcr(code, ' SELECT trx_id');
cn_debug.print_msg('insert_trx: Generated INSERT statement.', 1);
fnd_file.put_line(fnd_file.Log, 'insert_trx: Generated INSERT statement.');
cn_utils.appindcr(code, 'cn_message_pkg.debug(''' || procedure_name || ': Inserted '' || trx_count || '' records into cn_trx.'');');
cn_utils.appindcr(code, 'fnd_file.put_line(fnd_file.Log,''' || procedure_name || ': Inserted '' || trx_count || '' records into cn_trx.'');');
cn_utils.appindcr(code, 'UPDATE cn_not_trx cnt');
cn_utils.appindcr(code, 'cn_message_pkg.debug(''' || procedure_name || ': Updated collected_flag in cn_not_trx.'');');
cn_utils.appindcr(code, 'fnd_file.put_line(fnd_file.Log,''' || procedure_name || ': Updated collected_flag in cn_not_trx.'');');
cn_debug.print_msg('insert_trx<<', 1);
fnd_file.put_line(fnd_file.Log, 'insert_trx<<');
cn_debug.print_msg('insert_trx: in exception handler for NO_DATA_FOUND', 1);
fnd_file.put_line(fnd_file.Log, 'insert_trx: in exception handler for NO_DATA_FOUND');
END insert_trx;
PROCEDURE update_trx (
procedure_name cn_obj_procedures_v.name%TYPE,
x_module_id cn_modules.module_id%TYPE,
x_event_id cn_events.event_id%TYPE,
code IN OUT NOCOPY cn_utils.code_type,
x_org_id IN NUMBER) IS
CURSOR header_direct_maps IS
SELECT LOWER(destcol.name) dest_column,
cm.expression expression
FROM cn_table_maps tm,
cn_column_maps cm,
cn_objects destcol
WHERE tm.mapping_type = 'INV1'
AND cm.table_map_id = tm.table_map_id
AND cm.expression IS NOT NULL
AND cm.destination_column_id = destcol.object_id
-- Added for MOAC by Ashley
AND tm.org_id = x_org_id
AND cm.org_id = tm.org_id
AND destcol.org_id = cm.org_id
ORDER BY destcol.name;
cn_utils.appendcr(code, '--******** UPDATE CN_TRX ********-- ');
cn_debug.print_msg('update_trx>>', 1);
fnd_file.put_line(fnd_file.Log, 'update_trx>>');
cn_debug.print_msg('update_trx: x_module_id = ' || x_module_id, 1);
cn_debug.print_msg('update_trx: Generating UPDATE statement. ', 1);
fnd_file.put_line(fnd_file.Log, 'update_trx: Generating UPDATE statement. ');
cn_utils.appindcr(code, 'UPDATE cn_trx ct');
cn_utils.appindcr(code, ' SELECT rctt.type');
cn_utils.appindcr(code, 'UPDATE cn_trx ct');
cn_utils.appindcr(code, 'UPDATE cn_trx ct');
cn_utils.appindcr(code, ' SELECT rct.trx_date');
cn_utils.appindcr(code, 'UPDATE cn_trx ct');
cn_utils.appindcr(code, 'SELECT');
cn_utils.appindcr(code, 'trx_update_count := SQL%ROWCOUNT;');
cn_debug.print_msg('update_trx: Generated UPDATE statement.', 1);
fnd_file.put_line(fnd_file.Log, 'update_trx: Generated UPDATE statement.');
cn_utils.appindcr(code, 'cn_message_pkg.debug(''' || procedure_name || ': Updated '' || trx_update_count || '' cn_trx.'');');
cn_utils.appindcr(code, 'fnd_file.put_line(fnd_file.Log,''' || procedure_name || ': Updated '' || trx_update_count || '' cn_trx.'');');
cn_debug.print_msg('update_trx<<', 1);
fnd_file.put_line(fnd_file.Log, 'update_trx<<');
cn_debug.print_msg('update_trx: in exception handler for NO_DATA_FOUND', 1);
fnd_file.put_line(fnd_file.Log, 'update_trx: in exception handler for NO_DATA_FOUND');
END update_trx;
PROCEDURE insert_lines (
procedure_name cn_obj_procedures_v.name%TYPE,
x_module_id cn_modules.module_id%TYPE,
x_event_id cn_events.event_id%TYPE,
code IN OUT NOCOPY cn_utils.code_type,
x_org_id IN NUMBER) IS
-- Declare cursor for inserting into the trx lines table
CURSOR lines_direct_maps IS
SELECT LOWER(destcol.name) dest_column,
cm.expression expression
FROM cn_table_maps tm,
cn_column_maps cm,
cn_objects destcol
WHERE tm.mapping_type = 'INV2'
AND cm.table_map_id = tm.table_map_id
AND cm.expression IS NOT NULL
AND cm.destination_column_id = destcol.object_id
-- Added for MOAC by Ashley
AND tm.org_id = x_org_id
AND cm.org_id = tm.org_id
AND destcol.org_id = cm.org_id
ORDER BY destcol.name;
cn_utils.appendcr(code, '--******** INSERT CN_TRX_LINES *********-- ');
cn_debug.print_msg('insert_lines>>', 1);
fnd_file.put_line(fnd_file.Log, 'insert_lines>>');
cn_debug.print_msg('insert_lines: x_module_id = ' || x_module_id, 1);
cn_debug.print_msg('insert_lines: Generating INSERT statement.', 1);
fnd_file.put_line(fnd_file.Log, 'insert_lines: Generating INSERT statement.');
cn_utils.appindcr(code, 'cn_message_pkg.debug(''' || procedure_name || ': Inserting into CN_TRX_LINES .'');');
cn_utils.appindcr(code, 'fnd_file.put_line(fnd_file.Log,''' || procedure_name || ': Inserting into CN_TRX_LINES .'');');
cn_utils.appindcr(code, 'INSERT INTO cn_trx_lines(');
cn_utils.appindcr(code, 'SELECT');
cn_debug.print_msg('insert_lines: Generated INSERT statement.', 1);
fnd_file.put_line(fnd_file.Log, 'insert_lines: Generated INSERT statement.');
cn_utils.appindcr(code, 'cn_message_pkg.debug(''' || procedure_name || ': Inserted '' || trx_line_count || '' records into cn_trx_lines.'');');
cn_utils.appindcr(code, 'fnd_file.put_line(fnd_file.Log,''' || procedure_name || ': Inserted '' || trx_line_count || '' records into cn_trx_lines.'');');
cn_debug.print_msg('insert_lines<<', 1);
fnd_file.put_line(fnd_file.Log, 'insert_lines<<');
cn_debug.print_msg('insert_lines: in exception handler for NO_DATA_FOUND', 1);
fnd_file.put_line(fnd_file.Log, 'insert_lines: in exception handler for NO_DATA_FOUND');
END insert_lines;
PROCEDURE update_lines (
procedure_name cn_obj_procedures_v.name%TYPE,
x_module_id cn_modules.module_id%TYPE,
x_event_id cn_events.event_id%TYPE,
code IN OUT NOCOPY cn_utils.code_type,
x_org_id IN NUMBER) IS
BEGIN
l_org_id := x_org_id;
cn_utils.appendcr(code, '--******** UPDATE CN_TRX_LINES ********-- ');
cn_debug.print_msg('update_lines>>', 1);
fnd_file.put_line(fnd_file.Log, 'update_lines>>');
cn_debug.print_msg('update_lines: x_module_id = ' || x_module_id, 1);
cn_debug.print_msg('update_lines: Generating UPDATE statement.', 1);
fnd_file.put_line(fnd_file.Log, 'update_lines: Generating UPDATE statement.');
cn_utils.appindcr(code, 'UPDATE cn_trx_lines ctl');
cn_utils.appindcr(code, ' SELECT ');
cn_utils.appindcr(code, 'trx_line_update_count := SQL%ROWCOUNT;');
cn_debug.print_msg('update_lines: Generated UPDATE statement.', 1);
fnd_file.put_line(fnd_file.Log, 'update_lines: Generated UPDATE statement.');
cn_utils.appindcr(code, 'cn_message_pkg.debug(''' || procedure_name || ': Updated '' || trx_line_update_count || '' cn_trx_lines.'');');
cn_utils.appindcr(code, 'fnd_file.put_line(fnd_file.Log, ''' || procedure_name || ': Updated '' || trx_line_update_count || '' cn_trx_lines.'');');
cn_debug.print_msg('update_lines<<', 1);
fnd_file.put_line(fnd_file.Log, 'update_lines<<');
cn_debug.print_msg('update_lines: in exception handler for NO_DATA_FOUND', 1);
fnd_file.put_line(fnd_file.Log, 'update_lines: in exception handler for NO_DATA_FOUND');
END update_lines;
PROCEDURE insert_sales_lines (
procedure_name cn_obj_procedures_v.name%TYPE,
x_module_id cn_modules.module_id%TYPE,
x_event_id cn_events.event_id%TYPE,
code IN OUT NOCOPY cn_utils.code_type,
x_org_id IN NUMBER) IS
-- Declare cursor for inserting into the sales_lines table
CURSOR sales_lines_direct_maps IS
SELECT LOWER(destcol.name) dest_column,
cm.expression expression
FROM cn_table_maps tm,
cn_column_maps cm,
cn_objects destcol
WHERE tm.mapping_type = 'INV3'
AND cm.table_map_id = tm.table_map_id
AND cm.expression IS NOT NULL
AND cm.destination_column_id = destcol.object_id
-- Added for MOAC by Ashley
AND tm.org_id = x_org_id
AND cm.org_id = tm.org_id
AND destcol.org_id = cm.org_id
AND destcol.name <> 'QUANTITY' -- Fix bug 2809039
ORDER BY destcol.name;
cn_utils.appendcr(code, '--******** INSERT CN_TRX_SALES_LINES ********-- ');
cn_debug.print_msg('insert_sales_lines>>', 1);
fnd_file.put_line(fnd_file.Log, 'insert_sales_lines>>');
cn_debug.print_msg('insert_sales_lines: x_module_id = ' || x_module_id, 1);
cn_debug.print_msg('insert_sales_lines: Updating object dependencies and module object maps.', 1);
fnd_file.put_line(fnd_file.Log, 'insert_sales_lines: Updating object dependencies and module object maps.');
cn_debug.print_msg('insert_sales_lines: Generating INSERT statement.', 1);
fnd_file.put_line(fnd_file.Log, 'insert_sales_lines: Generating INSERT statement.');
cn_utils.appindcr(code, 'cn_message_pkg.debug(''' || procedure_name || ': Inserting into CN_TRX_SALES_LINES .'');');
cn_utils.appindcr(code, 'fnd_file.put_line(fnd_file.Log, ''' || procedure_name || ': Inserting into CN_TRX_SALES_LINES .'');');
cn_utils.appindcr(code, 'INSERT INTO cn_trx_sales_lines (');
cn_utils.appindcr(code, 'last_updated_by,');
cn_utils.appindcr(code, 'last_update_date,');
cn_utils.appindcr(code, 'last_update_login,');
cn_utils.appindcr(code, 'SELECT');
cn_utils.appindcr(code, 'x_last_updated_by,');
cn_utils.appindcr(code, 'x_last_update_date,');
cn_utils.appindcr(code, 'x_last_update_login,');
cn_utils.appindcr(code, ' (SELECT 1 ');
cn_utils.appindcr(code, ' (select 1');
cn_utils.appindcr(code, ' (SELECT 1');
cn_debug.print_msg('insert_sales_lines: Generated INSERT statement.', 1);
fnd_file.put_line(fnd_file.Log, 'insert_sales_lines: Generated INSERT statement.');
cn_utils.appindcr(code, 'cn_message_pkg.debug(''' || procedure_name || ': Inserted '' || trx_sales_line_count || '' records into cn_trx_sales_lines.'');');
cn_utils.appindcr(code, 'fnd_file.put_line(fnd_file.Log, ''' || procedure_name || ': Inserted '' || trx_sales_line_count || '' records into cn_trx_sales_lines.'');');
cn_debug.print_msg('insert_sales_lines<<', 1);
fnd_file.put_line(fnd_file.Log, 'insert_sales_lines<<');
cn_utils.appindcr(code, 'UPDATE cn_trx_lines');
cn_utils.appindcr(code, 'cn_message_pkg.debug(''' || procedure_name || ': Updated collected_flag in cn_trx_lines.'');');
cn_utils.appindcr(code, 'fnd_file.put_line(fnd_file.Log, ''' || procedure_name || ': Updated collected_flag in cn_trx_lines.'');');
cn_debug.print_msg('insert_sales_lines: in exception handler for NO_DATA_FOUND', 1);
fnd_file.put_line(fnd_file.Log, 'insert_sales_lines: in exception handler for NO_DATA_FOUND');
END insert_sales_lines;
PROCEDURE update_sales_lines (
procedure_name cn_obj_procedures_v.name%TYPE,
x_module_id cn_modules.module_id%TYPE,
x_event_id cn_events.event_id%TYPE,
code IN OUT NOCOPY cn_utils.code_type,
x_org_id IN NUMBER) IS
BEGIN
l_org_id := x_org_id;
cn_utils.appendcr(code, '--******** UPDATE CN_TRX_SALES_LINES ********-- ');
cn_debug.print_msg('update_sales_lines>>', 1);
fnd_file.put_line(fnd_file.Log, 'update_sales_lines>>');
cn_debug.print_msg('update_sales_lines: x_module_id = ' || x_module_id, 1);
cn_debug.print_msg('update_sales_lines: Generating UPDATE statement.', 1);
fnd_file.put_line(fnd_file.Log, 'update_sales_lines: Generating UPDATE statement.');
cn_utils.appindcr(code, 'UPDATE cn_trx_sales_lines ctsl');
cn_utils.appindcr(code, ' SELECT ');
cn_utils.appindcr(code, ' SELECT ct.processed_date, ct.rollup_date');
cn_utils.appindcr(code, ' SELECT cp.period_id');
cn_utils.appindcr(code, ' SELECT cp.period_id');
cn_utils.appindcr(code, 'UPDATE cn_trx_sales_lines ctsl');
cn_utils.appindcr(code, 'trx_sales_line_update_count := SQL%ROWCOUNT;');
cn_debug.print_msg('update_sales_lines: Generated UPDATE statement.', 1);
fnd_file.put_line(fnd_file.Log, 'update_sales_lines: Generated UPDATE statement.');
cn_utils.appindcr(code, 'cn_message_pkg.debug(''' || procedure_name || ': Updated '' || trx_sales_line_update_count || '' records in cn_trx_sales_lines.'');');
cn_utils.appindcr(code, 'fnd_file.put_line(fnd_file.Log, ''' || procedure_name || ': Updated '' || trx_sales_line_update_count || '' records in cn_trx_sales_lines.'');');
cn_debug.print_msg('update_sales_lines<<', 1);
fnd_file.put_line(fnd_file.Log, 'update_sales_lines<<');
cn_debug.print_msg('update_sales_lines: in exception handler for NO_DATA_FOUND', 1);
fnd_file.put_line(fnd_file.Log, 'update_sales_lines: in exception handler for NO_DATA_FOUND');
END update_sales_lines;
PROCEDURE update_invoice_total (
procedure_name cn_obj_procedures_v.name%TYPE,
code IN OUT NOCOPY cn_utils.code_type,
x_org_id IN NUMBER) IS
BEGIN
l_org_id := x_org_id;
cn_utils.appendcr(code, '--******** UPDATE INVOICE TOTAL ********-- ');
cn_debug.print_msg('update_invoice_total: Generating UPDATE statement.', 1);
fnd_file.put_line(fnd_file.Log, 'update_invoice_total: Generating UPDATE statement.');
cn_utils.appindcr(code, '-- This could not be done when we updated cn_trx earlier ');
cn_utils.appindcr(code, 'UPDATE cn_trx ct');
cn_utils.appindcr(code, ' SELECT SUM(ctl.extended_amount)');
cn_utils.appindcr(code, 'cn_message_pkg.debug(''' || procedure_name || ': Updated cn_trx invoice_total.'');');
cn_utils.appindcr(code, 'fnd_file.put_line(fnd_file.Log, ''' || procedure_name || ': Updated cn_trx invoice_total.'');');
cn_debug.print_msg('update_invoice_total: Generated UPDATE statement.', 1);
fnd_file.put_line(fnd_file.Log, 'update_invoice_total: Generated UPDATE statement.');
END update_invoice_total;
PROCEDURE insert_comm_lines (
procedure_name cn_obj_procedures_v.name%TYPE,
x_module_id cn_modules.module_id%TYPE,
x_event_id cn_events.event_id%TYPE,
code IN OUT NOCOPY cn_utils.code_type,
x_org_id IN NUMBER) IS
x_row_count NUMBER := 0;
SELECT LOWER(destcol.name) dest_column,
ccm.expression
FROM cn_column_maps ccm,
cn_table_maps tm,
cn_objects destcol
WHERE tm.mapping_type = 'AR'
AND ccm.table_map_id = tm.table_map_id
AND (ccm.column_map_id > 0 -- New mappings to Attribute columns
OR ccm.modified = 'Y') -- User has modified a seeded mapping
AND ccm.expression IS NOT NULL
AND ccm.calc_ext_table_id IS NULL -- Not a foreign-key indirect mapping
AND ccm.update_clause IS NULL -- Not a free-form indirect mapping
AND destcol.object_id = ccm.destination_column_id
AND destcol.table_id = -1008 -- cn_comm_lines_api (exclude any old mappings to cn_trx etc.)
-- Added for MOAC by Ashley
AND tm.org_id = x_org_id
AND ccm.org_id = tm.org_id
AND destcol.org_id = ccm.org_id
ORDER BY destcol.name;
cn_utils.appendcr(code, '--******** INSERT CN_COMM_LINES_API ********-- ');
cn_debug.print_msg('insert_comm_lines_api>>', 1);
fnd_file.put_line(fnd_file.Log, 'insert_comm_lines_api>>');
cn_debug.print_msg('insert_sales_lines: Generating INSERT statement.', 1);
fnd_file.put_line(fnd_file.Log, 'insert_sales_lines: Generating INSERT statement.');
cn_utils.appindcr(code, 'cn_message_pkg.debug(''' || procedure_name || ': Inserting into CN_COMM_LINES_API .'');');
cn_utils.appindcr(code, 'fnd_file.put_line(fnd_file.Log, ''' || procedure_name || ': Inserting into CN_COMM_LINES_API .'');');
cn_utils.appindcr(code, 'INSERT INTO cn_comm_lines_api (');
cn_utils.appindcr(code, 'last_updated_by,');
cn_utils.appindcr(code, 'last_update_date,');
cn_utils.appindcr(code, 'last_update_login,');
cn_utils.appindcr(code, 'SELECT /*+ ordered index(CTSL CN_TRX_SALES_LINES_N3) index(CTL CN_TRX_LINES_N4) */');
cn_utils.appindcr(code, 'SELECT /*+ ordered index(CTSL CN_TRX_SALES_LINES_N2) index(CTL CN_TRX_LINES_N3) */');
cn_utils.appindcr(code, 'x_last_updated_by,');
cn_utils.appindcr(code, 'x_last_update_date,');
cn_utils.appindcr(code, 'x_last_update_login,');
cn_utils.appindcr(code, 'cn_message_pkg.debug(''' || procedure_name || ': Inserted '' || comm_lines_api_count || '' records into CN_COMM_LINES_API.'');');
cn_utils.appindcr(code, 'fnd_file.put_line(fnd_file.Log, ''' || procedure_name || ': Inserted '' || comm_lines_api_count || '' records into CN_COMM_LINES_API.'');');
cn_utils.appindcr(code, '--*** Update columns populated by user-defined DIRECT mappings');
SELECT LOWER(NVL(alias,name)) INTO x_cnt_alias
FROM cn_obj_tables_v
WHERE name = 'CN_NOT_TRX' AND org_id = x_org_id; --Added for MOAC by Ashley
SELECT LOWER(NVL(alias,name)) INTO x_rct_alias
FROM cn_obj_tables_v
WHERE name = 'RA_CUSTOMER_TRX' AND org_id = x_org_id; --Added for MOAC by Ashley
SELECT LOWER(NVL(alias,name)) INTO x_rctl_alias
FROM cn_obj_tables_v
WHERE name = 'RA_CUSTOMER_TRX_LINES' AND org_id = x_org_id; --Added for MOAC by Ashley
SELECT LOWER(NVL(alias,name)) INTO x_rctls_alias
FROM cn_obj_tables_v
WHERE name = 'RA_CUST_TRX_LINE_SALESREPS' AND org_id = x_org_id; --Added for MOAC by Ashley
cn_utils.appindcr(code, 'UPDATE cn_comm_lines_api api');
cn_utils.appindcr(code, 'SELECT');
cn_utils.appindcr(code, 'comm_lines_api_update_count := SQL%ROWCOUNT;');
cn_utils.appindcr(code, 'cn_message_pkg.debug(''' || procedure_name || ': For user DIRECT mappings, updated '' || comm_lines_api_update_count || '' records in CN_COMM_LINES_API.'');');
cn_utils.appindcr(code, 'fnd_file.put_line(fnd_file.Log, ''' || procedure_name || ': For user DIRECT mappings, updated '' || comm_lines_api_update_count || '' records in CN_COMM_LINES_API.'');');
cn_debug.print_msg('insert_comm_lines: in exception handler for NO_DATA_FOUND', 1);
fnd_file.put_line(fnd_file.Log, 'insert_comm_lines: in exception handler for NO_DATA_FOUND');
END insert_comm_lines;