The following lines contain the word 'select', 'insert', 'update' or 'delete':
INSERT INTO igi_sls_upg_itf(SELECT a.table_name, a.owner , a.sls_table_name, NULL,NULL,NULL,get_sls_grps(a.table_name),NULL,NULL
FROM igi_sls_secure_tables a
WHERE a.table_name IN( 'PO_VENDORS','PO_VENDOR_CONTACTS', 'PO_VENDOR_SITES_ALL')
AND A.table_name NOT IN (SELECT old_table_name FROM igi_sls_upg_itf)
AND a.table_name IN (SELECT sls_allocation FROM igi_sls_allocations));
SELECT distinct old_table_name BULK COLLECT INTO l_list
FROM igi_sls_upg_itf ORDER BY old_table_name;
SELECT new_table_name BULK COLLECT INTO l_list FROM igi_sls_upg_itf ORDER BY new_table_name;
SELECT COUNT(*) INTO l_count FROM igi_sls_allocations WHERE sls_allocation = p_table_name ;
(SELECT sls_group FROM igi_sls_allocations WHERE sls_allocation = p_table_name)
LOOP
IF l_count=1 THEN
l_dummy:= l_dummy || sec_grp_rec.sls_group;
SELECT sls_groups INTO param2(indx) FROM igi_sls_upg_itf WHERE old_table_name=param1(indx);
write_to_log (l_excep_level, 'set_sls_tables_data','Error in insertion... Please note.. :)' );
SELECT COUNT(*) INTO l_count FROM igi_sls_secure_tables WHERE table_name =l_table_name ;
/** First select the owner of this table **/
SELECT owner INTO l_owner FROM all_objects WHERE object_name=UPPER(l_table_name)
AND object_type='TABLE' AND owner IN('AP', 'AR', 'PO', 'XLA','ICX','IBY');
SELECT 'IGI_SLS_' || TO_CHAR(igi_sls_extended_table_s.nextval)
INTO l_sls_table_name FROM dual;
SELECT OPTIMISE_SQL INTO l_optimise_sql FROM igi_sls_secure_tables WHERE table_name =l_old_table_name;
write_to_log (l_excep_level, 'set_sls_tables_data','Before insert' );
/* insert statement... core to this procedure..*/
INSERT INTO igi_sls_secure_tables(owner, table_name, sls_table_name, update_allowed, creation_date, created_by,
last_update_login,last_update_date, last_updated_by, optimise_sql) VALUES(l_owner, l_table_name,l_sls_table_name, 'N', sysdate,1,1,sysdate,1, l_optimise_sql );
write_to_log (l_excep_level, 'set_sls_tables_data','After Insert..' ||SQL%ROWCOUNT ||'row inserted');
UPDATE igi_sls_upg_itf SET new_table_name=l_table_name,new_owner=l_owner, new_allocation=l_sls_table_name WHERE old_table_name = l_old_table_name;
SELECT ROWID BULK COLLECT INTO l_list FROM igi_sls_allocations WHERE sls_allocation =l_old_table_name;
SELECT sls_group INTO l_sls_group FROM igi_sls_allocations WHERE ROWID=l_rowid;
SELECT COUNT(*) INTO l_count FROM igi_sls_allocations WHERE sls_group=l_sls_group
AND sls_allocation = l_table_name;
/** Insert only if the entry is not present.. */
IF(l_count =0)THEN
INSERT INTO igi_sls_allocations (SELECT SLS_GROUP ,SLS_GROUP_TYPE ,l_table_name ,SLS_ALLOCATION_TYPE,
SYSDATE ,null,null,null,SYSDATE ,CREATED_BY,1,sysdate,1 FROM
igi_sls_allocations WHERE ROWID=l_rowid) ;
update igi_sls_secure_tables set table_name='PO_VENDORS_OBS'
where table_name='PO_VENDORS';
update igi_sls_secure_tables set table_name='PO_VENDOR_CONTACTS_OBS'
where table_name='PO_VENDOR_CONTACTS';
update igi_sls_secure_tables set table_name='PO_VENDOR_SITES_OBS'
where table_name='PO_VENDOR_SITES_ALL';
update igi_sls_allocations set sls_allocation='PO_VENDORS_OBS'
where sls_allocation='PO_VENDORS';
update igi_sls_allocations set sls_allocation='PO_VENDOR_CONTACTS_OBS'
where sls_allocation='PO_VENDOR_CONTACTS';
update igi_sls_allocations set sls_allocation='PO_VENDOR_SITES_OBS'
where sls_allocation='PO_VENDOR_SITES_ALL';
delete from IGI_GCC_INST_OPTIONS_ALL where OPTION_NAME='SLS';
UPDATE igi_sls_upg_itf SET from_clause=param2(indx) , where_clause=param3(indx)
WHERE old_table_name=param1(indx) AND param3(indx) IS NOT NULL;
write_to_log (l_excep_level, 'set_query_data',SQL%ROWCOUNT ||' rows updated' );
l_select VARCHAR2(3000);
SELECT old_allocation, new_allocation INTO l_sls_tab_old, l_sls_tab_new FROM igi_sls_upg_itf
WHERE old_table_name=param1(indx);
l_select := ' SELECT DISTINCT b.ROWID , c.SLS_SEC_GRP , ' ||
' c.PREV_SLS_SEC_GRP , c.CHANGE_DATE FROM '|| l_from || ' WHERE a.ROWID=c.SLS_ROWID AND '|| param4(indx) ||
' AND NOT EXISTS (SELECT ''X''' || ' FROM ' || l_sls_tab_new ||' e '|| ' WHERE b.rowid = e.sls_rowid )';
write_to_log (l_excep_level, 'migrate_data','Select Statement Executed'||l_select );
l_query:= ' INSERT INTO '|| l_sls_tab_new ||'(' || l_select ||')';
INSERT INTO new_allocation( SELECT DISTINCT b.ROWID , c.sls_sec_group,
c.PREV_SLS_SEC_GRP , c.CHANGE_DATE FROM
param1(indx) a ,param2(indx) b , old_allocation c
WHERE a.ROWID=c.row_id) AND param3(indx));
write_to_log (l_excep_level, 'migrate_data',SQL%ROWCOUNT ||' rows inserted' );
write_to_log (l_excep_level, 'migrate_data','Error in insertion... Please note.. :)' );