I have the following the snippet of procedure the is using an existing table as a parameter, but every time I run it I get an error saying the "table doesn't exist" I guess it is not recognizing the parameter correctly. PLEASE HELP:
create or replace procedure nc_new_customer_analysis (v_new_customers string)
as
BEGIN
execute immediate 'truncate table nc_internet_sales';
execute immediate 'truncate table nc_broadcast_sales';
execute immediate 'truncate table nc_all_sales';
--***********************************************************************************************
--Breakdown of INTERNET ONLY New Customer Sales
--***********************************************************************************************
--CREATE TABLE nc_internet_sales AS (
execute immediate 'insert into nc_internet_sales
SELECT /*+ ORDERED USE_NL(O L) INDEX(L) */
nc.min_id,
COUNT(DISTINCT o.order_no) orders_inet,
COUNT(DISTINCT DECODE(NVL(o.order_ref, 0 ),0, o.order_no,o.order_ref)) carts_inet,
MIN(o.order_date) first_order_inet,
MAX(o.order_date) last_order_inet,
SUM(l.uprice*(l.qty-NVL(l.qty_returned, 0))) gross_sales_inet,
SUM((CASE
WHEN l.litem_id = 1
THEN o.shipping
ELSE 0
END)) shipping_inet,
SUM(l.qty) qty_ordered_inet,
SUM(NVL(l.qty_returned,0)) qty_returned_inet
FROM :1 nc,
acntv.orders o,
acntv.litem l
WHERE nc.cust_id = o.cust_id AND
o.order_no = l.order_no AND
miccom1.selling_channel(o.batch, o.ctype_id) = "INET" AND
o.order_type = "O" AND
o.ostatus <> "X"
GROUP BY nc.min_id' using v_new_customers;
commit;
create or replace procedure nc_new_customer_analysis (v_new_customers string)
as
BEGIN
execute immediate 'truncate table nc_internet_sales';
execute immediate 'truncate table nc_broadcast_sales';
execute immediate 'truncate table nc_all_sales';
--***********************************************************************************************
--Breakdown of INTERNET ONLY New Customer Sales
--***********************************************************************************************
--CREATE TABLE nc_internet_sales AS (
execute immediate 'insert into nc_internet_sales
SELECT /*+ ORDERED USE_NL(O L) INDEX(L) */
nc.min_id,
COUNT(DISTINCT o.order_no) orders_inet,
COUNT(DISTINCT DECODE(NVL(o.order_ref, 0 ),0, o.order_no,o.order_ref)) carts_inet,
MIN(o.order_date) first_order_inet,
MAX(o.order_date) last_order_inet,
SUM(l.uprice*(l.qty-NVL(l.qty_returned, 0))) gross_sales_inet,
SUM((CASE
WHEN l.litem_id = 1
THEN o.shipping
ELSE 0
END)) shipping_inet,
SUM(l.qty) qty_ordered_inet,
SUM(NVL(l.qty_returned,0)) qty_returned_inet
FROM :1 nc,
acntv.orders o,
acntv.litem l
WHERE nc.cust_id = o.cust_id AND
o.order_no = l.order_no AND
miccom1.selling_channel(o.batch, o.ctype_id) = "INET" AND
o.order_type = "O" AND
o.ostatus <> "X"
GROUP BY nc.min_id' using v_new_customers;
commit;