The following lines contain the word 'select', 'insert', 'update' or 'delete':
select plan_id,
inventory_item_id,
company_id,
company_site_id,
exception_group,
exception_type,
count(*)
from msc_x_exception_details
where plan_id = -1
and exception_group IN (1,2,4,6,7,8)
group by plan_id,
inventory_item_id,
company_id,
company_site_id,
exception_group,
exception_type;
PROCEDURE UPDATE_EXCEPTION_SUMMARY(p_summary_status OUT NOCOPY NUMBER) IS
BEGIN
BEGIN
OPEN excepSummary;
LOG_MESSAGE('Delete Exceptions : Error while fetching exception summary');
LOG_MESSAGE('Updated Exception Summary - '||a_plan_id.COUNT);
update msc_item_exceptions
set exception_count = a_count(i)
where plan_id = a_plan_id(i)
and company_id = a_company_id(i)
and company_site_id = a_company_site_id(i)
and inventory_item_id = a_inventory_item_id(i)
and exception_type = a_exception_type(i)
and exception_group = a_exception_group(i)
and version = 0;
LOG_MESSAGE('Delete Exceptions : Error while updating Exception Summary');
END UPDATE_EXCEPTION_SUMMARY;
' delete msc_x_exception_details '
||' where exception_type '|| G_EXCEP_TYPES
||' and exception_group '|| G_EXCEP_GROUPS
||' and company_id = 1 '
||' and company_site_id '|| l_site_string
||' and plan_id = -1 ';
' delete msc_x_exception_details '
||' where exception_type '|| G_EXCEP_TYPES
||' and exception_group '|| G_EXCEP_GROUPS
||' and customer_id = 1 '
||' and customer_site_id '||l_site_string
||' and plan_id = -1';
' delete msc_x_exception_details '
||' where exception_type '|| G_EXCEP_TYPES
||' and exception_group '|| G_EXCEP_GROUPS
||' and supplier_id = 1 '
||' and supplier_site_id '|| l_site_string
||' and plan_id = -1';
delete msc_item_exceptions mie
where
plan_id = -1
and exception_group in (1,2,4,6,7,8)
and not exists( select 1
from msc_x_exception_details med
where med.company_id = mie.company_id
and med.company_site_id = mie.company_site_id
and med.plan_id = mie.plan_id
and med.plan_id = -1
and med.inventory_item_id = mie.inventory_item_id
and med.exception_type = mie.exception_type
and med.exception_group = mie.exception_group);
LOG_MESSAGE('Delete Exceptions : Error while fetching exception summary');
LOG_MESSAGE('Updated Exception Summary - '||a_plan_id.COUNT);
update msc_item_exceptions
set exception_count = a_count(i)
where plan_id = a_plan_id(i)
and company_id = a_company_id(i)
and company_site_id = a_company_site_id(i)
and inventory_item_id = a_inventory_item_id(i)
and exception_type = a_exception_type(i)
and exception_group = a_exception_group(i)
and version = 0;
LOG_MESSAGE('Delete Exceptions : Error while updating Exception Summary');
-- Delete exceptions which do not have transaction_ids present in
-- msc_sup_dem_entries
--===============================================================
v_sql_stmt := null;
' delete msc_x_exception_details med '
||' where transaction_id1 is not null'
||' and exception_type '||G_DUPLICATE_EXCEP_TYPES
||' and exception_group '||G_EXCEP_GROUPS
||' and not exists ( select 1 '
||' from msc_sup_dem_entries msde'
||' where msde.transaction_id = med.transaction_id1)';
LOG_MESSAGE('No. of deleted exceptions where first transaction does not present in CP transactions - '||SQL%ROWCOUNT);
' delete msc_x_exception_details med '
||' where transaction_id2 is not null '
||' and exception_type '||G_DUPLICATE_EXCEP_TYPES
||' and exception_group '||G_EXCEP_GROUPS
||' and not exists ( select 1 '
||' from msc_sup_dem_entries msde '
||' where msde.transaction_id = med.transaction_id2)';
LOG_MESSAGE('No. of deleted exceptions where second transaction does not present in CP transactions - '||SQL%ROWCOUNT);
UPDATE_EXCEPTION_SUMMARY(l_summary_status);