The following lines contain the word 'select', 'insert', 'update' or 'delete':
SELECT apwl.product_category_id,
apwl.product_cat_set_id,
SUM(DECODE(apwl.FORECAST_AMOUNT_FLAG,'N',1,0)+R.CONVERSION_STATUS_FLAG) CONVERSION_FLAG ,
SUM(ROUND(apwl.WORST_FORECAST_AMOUNT*R.CONVERSION_RATE,0)),
SUM(ROUND(apwl.FORECAST_AMOUNT*R.CONVERSION_RATE,0)),
SUM(ROUND(apwl.BEST_FORECAST_AMOUNT*R.CONVERSION_RATE,0))
FROM as_prod_worksheet_lines apwl,
AS_PERIOD_RATES R,
as_pe_int_categories apic
WHERE apwl.product_category_id = apic.product_category_id
AND apwl.product_cat_set_id = apic.product_cat_set_id
AND apic.quota_id = c_quota_id
AND apwl.salesforce_id = c_resource_id
AND apwl.period_name = c_period_name
AND apwl.status_code ='SAVED'
AND apwl.end_date_active is null
AND apwl.credit_type_id = c_credit_type_id
AND R.PERIOD_SET_NAME = c_calendar
AND R.PERIOD_NAME = c_period_name
AND R.TO_CURRENCY= c_toCurrency
AND R.FROM_CURRENCY=apwl.CURRENCY_CODE
GROUP BY
apwl.product_category_id,
apwl.product_cat_set_id
UNION
SELECT apwl.product_category_id,
apwl.product_cat_set_id,
SUM(DECODE(apwl.FORECAST_AMOUNT_FLAG,'N',1,0)+R.CONVERSION_STATUS_FLAG) CONVERSION_FLAG ,
SUM(ROUND(apwl.WORST_FORECAST_AMOUNT*R.CONVERSION_RATE,0)),
SUM(ROUND(apwl.FORECAST_AMOUNT*R.CONVERSION_RATE,0)),
SUM(ROUND(apwl.BEST_FORECAST_AMOUNT*R.CONVERSION_RATE,0))
FROM as_prod_worksheet_lines apwl,
as_pe_int_categories apic,
as_sales_groups_v sg,
AS_PERIOD_RATES R,
gl_periods pd
WHERE apwl.product_category_id = apic.product_category_id
AND apwl.product_cat_set_id = apic.product_cat_set_id
AND apic.quota_id = c_quota_id
AND pd.period_name= c_period_name
AND pd.period_set_name ='Accounting'
AND sg.manager_salesforce_id = c_resource_id
AND (sg.mgr_start_date <= pd.end_date or sg.mgr_start_date is null)
AND (sg.mgr_end_date >= pd.start_date or sg.mgr_end_date is null)
AND apwl.salesforce_id is null
AND apwl.sales_group_id = sg.sales_group_id
AND apwl.period_name =c_period_name
AND apwl.status_code ='SAVED'
AND apwl.end_date_active is null
AND apwl.credit_type_id = c_credit_type_id
AND R.PERIOD_SET_NAME = c_calendar
AND R.PERIOD_NAME = c_period_name
AND R.TO_CURRENCY= c_toCurrency
AND R.FROM_CURRENCY=apwl.CURRENCY_CODE
GROUP BY
apwl.product_category_id,
apwl.product_cat_set_id;