The following lines contain the word 'select', 'insert', 'update' or 'delete':
PROCEDURE insert_cn_not_trx (
x_table_map_id cn_table_maps.table_map_id%TYPE,
x_event_id cn_events.event_id%TYPE,
code IN OUT NOCOPY cn_utils.code_type,
x_org_id IN NUMBER)
IS
l_return_status VARCHAR2(4000);
SELECT tmov.object_id, LOWER(OBJ.name) object_name
FROM cn_table_map_objects tmov, cn_objects obj
WHERE tmov.table_map_id = x_table_map_id
AND tmov.tm_object_type = 'PARAM'
and obj.object_id = tmov.object_id
and tmov.org_id = obj.org_id
AND tmov.org_id = x_org_id;
SELECT *
INTO l_table_map_rec
FROM cn_table_maps_v
WHERE table_map_id = x_table_map_id
AND org_id = l_org_id; -- Added For R12 MOAC Change
cn_utils.appindcr(code, 'cn_message_pkg.debug(''Inserting new transactions into CN_NOT_TRX.'');');
cn_utils.appindcr(code, 'fnd_file.put_line(fnd_file.Log,''Inserting new transactions into CN_NOT_TRX.'');');
cn_utils.appindcr(code, 'DECLARE -- Notification Insert Block');
cn_utils.appindcr(code, 'SELECT object_value');
cn_utils.appindcr(code, '-- Insert new lines into cn_not_trx');
cn_utils.appindcr(code, 'INSERT /'||'*+ PARALLEL(cn_not_trx) */ INTO cn_not_trx (');
cn_utils.appindcr(code, 'INSERT INTO cn_not_trx (');
cn_utils.appindcr(code, 'SELECT '||l_parallel_hint);
cn_utils.appindcr(code, 'SELECT ');
cn_utils.appindcr(code, ' SELECT /'||'*'||'+ PARALLEL(cn_not_trx) '||'*/ 1');
cn_utils.appindcr(code, ' SELECT 1');
cn_utils.appindcr(code, 'END; -- Notification Insert Block');
cn_utils.appindcr(code, '-- Commit the notification inserts - they are permanent even if collection fails');
END insert_cn_not_trx;
PROCEDURE insert_comm_lines_api_select(
x_table_map_id IN cn_table_maps_v.table_map_id%TYPE,
code IN OUT NOCOPY cn_utils.code_type,
x_org_id IN NUMBER,
x_parallel_hint IN VARCHAR2)
IS -- Added For R12 MOAC Changes
CURSOR api_direct_maps IS
SELECT column_map_id, expression, cno.NAME dest_column FROM cn_column_maps ccmv, cn_objects cno
WHERE ccmv.table_map_id = x_table_map_id
AND ccmv.expression IS NOT NULL
AND ccmv.calc_ext_table_id IS NULL
AND ccmv.update_clause IS NULL
AND ccmv.org_id = x_org_id
AND ccmv.destination_column_id = cno.object_id
AND ccmv.org_id = cno.org_id
-- Added For R12 MOAC Changes
ORDER BY dest_column;
cn_utils.appindcr(code, 'INSERT /'||'*+ PARALLEL(cn_comm_lines_api) */ INTO cn_comm_lines_api (');
cn_utils.appindcr(code, 'INSERT INTO cn_comm_lines_api (');
cn_utils.appindcr(code, 'INSERT INTO cn_comm_lines_api (');
cn_utils.appindcr(code, 'SELECT '||x_parallel_hint);
cn_utils.appindcr(code, 'SELECT ');
END insert_comm_lines_api_select;
PROCEDURE insert_comm_lines_api (
x_table_map_id cn_table_maps.table_map_id%TYPE,
x_event_id cn_events.event_id%TYPE,
code IN OUT NOCOPY cn_utils.code_type,
x_org_id IN NUMBER)
IS
l_return_status VARCHAR2(4000);
SELECT *
INTO l_table_map_rec
FROM cn_table_maps_v
WHERE table_map_id = x_table_map_id
AND org_id = l_org_id;
cn_utils.appendcr(code, '--******** INSERT CN_COMM_LINES_API *********-- ');
cn_utils.appindcr(code, 'cn_message_pkg.debug(''Inserting into CN_COMM_LINES_API.'');');
cn_utils.appindcr(code, 'fnd_file.put_line(fnd_file.Log, ''Inserting into CN_COMM_LINES_API.'');');
cn_utils.appindcr(code, '-- Insert new lines into CN_COMM_LINES_API');
insert_comm_lines_api_select(x_table_map_id, code, X_org_id, l_parallel_hint);
cn_utils.appindcr(code, 'cn_message_pkg.debug(''Inserted '' || comm_lines_api_count || '' line records into CN_COMM_LINES_API.'');');
cn_utils.appindcr(code, 'fnd_file.put_line(fnd_file.Log,''Inserted '' || comm_lines_api_count || '' line records into CN_COMM_LINES_API.'');');
cn_utils.appindcr(code, 'UPDATE /'||'*+ PARALLEL(cnt) */ cn_not_trx cnt');
cn_utils.appindcr(code, 'UPDATE cn_not_trx cnt');
cn_utils.appindcr(code, 'cn_message_pkg.debug(''Updated collected_flag in cn_not_trx.'');');
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_comm_lines_api;
PROCEDURE update_comm_lines_api (
x_table_map_id cn_table_maps.table_map_id%TYPE,
code IN OUT NOCOPY cn_utils.code_type,
x_org_id IN NUMBER)
IS
x_dest_table_name cn_obj_tables_v.name%TYPE;
SELECT
cm.expression,
cm.calc_ext_table_id,
cm.update_clause,
ext.name relationship_name,
LOWER(obj.NAME) external_table_name,
LOWER(NVL(ext.alias,obj.NAME)) external_table_alias,
LOWER(destcol.name) dest_column
FROM
cn_column_maps cm,
cn_obj_columns_v destcol,
cn_calc_ext_tables ext,
cn_objects obj
WHERE
cm.table_map_id = x_table_map_id
AND cm.expression IS NOT NULL
AND (cm.calc_ext_table_id IS NOT NULL
OR cm.update_clause IS NOT NULL)
AND ext.calc_ext_table_id(+) = cm.calc_ext_table_id
AND obj.object_id(+) = ext.external_table_id
AND destcol.column_id = cm.destination_column_id
-- make sure no old pre 11iv2 mappings to CN_TRX etc. can slip in
AND destcol.table_id = -1008 --CN_COMM_LINES_API
AND cm.org_id = x_org_id
AND destcol.org_id = cm.org_id
AND ext.org_id(+) = cm.org_id
AND obj.org_id(+) = ext.org_id
ORDER BY destcol.name;
cn_utils.appendcr(code, '--******** UPDATE CN_COMM_LINES_API ********-- ');
cn_utils.appindcr(code, '--*** Update columns populated by all INDIRECT mappings');
SELECT
LOWER(cB.name),
LOWER(NVL(cB.alias , cB.name))
INTO
x_dest_table_name,
x_dest_alias
FROM cn_table_maps ctm, CN_OBJECTS CB
WHERE
ctm.table_map_id = x_table_map_id
and CB.object_id = CTM.destination_table_id
and cb.org_id = ctm.org_id
AND cb.org_id =x_org_id;
cn_utils.appindcr(code, 'UPDATE ' || x_dest_table_name || ' ' || x_dest_alias);
cn_utils.appindcr(code, ' SELECT ');
(SELECT LOWER(pkcol.name) pkcolumn_name,
LOWER(fkcol.name) fkcolumn_name
FROM cn_calc_ext_tbl_dtls dtls,
cn_obj_columns_v pkcol,
cn_obj_columns_v fkcol
WHERE dtls.calc_ext_table_id = indmap_rec.calc_ext_table_id
AND pkcol.column_id = dtls.external_column_id
AND fkcol.column_id = dtls.internal_column_id
AND dtls.org_id = x_org_id
AND pkcol.org_id = dtls.org_id
AND fkcol.org_id = pkcol.org_id)
LOOP
IF x_count = 0 THEN
x_count := 1;
cn_utils.appindcr(code, ' --*** FROM/WHERE taken from Update Clause');
cn_utils.appindcr(code, ' '||indmap_rec.update_clause||'),');
cn_utils.appindcr(code, 'cn_message_pkg.debug(''For all INDIRECT mappings updated '' || SQL%ROWCOUNT || '' rows in cn_comm_lines_api.'');');
cn_utils.appindcr(code, 'fnd_file.put_line(fnd_file.Log, ''For all INDIRECT mappings updated '' || SQL%ROWCOUNT || '' rows in cn_comm_lines_api.'');');
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_comm_lines_api;
l_delete_flag VARCHAR2(1);
SELECT OBJ.object_value
FROM cn_table_map_objects tmov, cn_objects obj
WHERE tmov.table_map_id = x_table_map_id
AND tmov.tm_object_type = 'FILTER'
and tmov.object_id = obj.object_id
and tmov.org_id = obj.org_id
AND tmov.org_id = x_org_id;
SELECT delete_flag
INTO l_delete_flag
FROM cn_table_maps
WHERE table_map_id = x_table_map_id
AND org_id = x_org_id;
IF l_delete_flag = 'Y' THEN
l_statement := 'DELETE FROM cn_comm_lines_api api';
l_statement := 'UPDATE cn_comm_lines_api api SET load_status = ''FILTERED''';
(SELECT OBJ.object_value
FROM cn_table_map_objects tmov, cn_objects obj
WHERE tmov.table_map_id = p_table_map_id
and obj.object_id = tmov.object_id
and tmov.org_id = obj.org_id
AND tmov.tm_object_type = 'USERCODE'
AND UPPER(OBJ.name) = UPPER(p_location_name)
AND tmov.org_id = x_org_id
ORDER BY table_map_object_id)
LOOP
--+
-- Add a terminal ';' if none was registered