OK. I've got an initial procedure that can be passeed an optional date parameter. I need those parameters to be able to be passed to a procedure that is called within the first procedure. Then I need those to be passed again to a third procedure which is called from the second. Make since?
So I have this sqlplus statement:
execute nc_begin-new_customer_process('01 jan 2007','01 feb 2007)
So that query looks like this:
create or replace procedure nc_begin-new_customer_process (begin_date date,end_date date)
is
BEGIN
blah blah blah...(right after all this is done I need to call a second procedure called nc_new_customer_alaysis
using the begin_date, and end_date passed above. I tried using
execute immediate 'nc_new_customer_analysis ('||start_date||','||end_date||')';
It compiles, but it doesn't work. What am I doing wrong?
The ('||start_date||','||end_date||')' parameter will be used in a query that looks like this.
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 nc_monthly_new_customers 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'' and
nc.order_date between to_date ('||start_date||',''mm/dd/yyyy HH12:MI:SS AM'') and to_date ('||end_date||',''mm/dd/yyyy HH12:MI:SS AM'');
GROUP BY nc.min_id';
commit;
I know this has to be confusing but I'm sure there is a simple way to do what I want to have happen. If you can decipher all this, I would appreciate any help you can give.
Thank you.
So I have this sqlplus statement:
execute nc_begin-new_customer_process('01 jan 2007','01 feb 2007)
So that query looks like this:
create or replace procedure nc_begin-new_customer_process (begin_date date,end_date date)
is
BEGIN
blah blah blah...(right after all this is done I need to call a second procedure called nc_new_customer_alaysis
using the begin_date, and end_date passed above. I tried using
execute immediate 'nc_new_customer_analysis ('||start_date||','||end_date||')';
It compiles, but it doesn't work. What am I doing wrong?
The ('||start_date||','||end_date||')' parameter will be used in a query that looks like this.
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 nc_monthly_new_customers 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'' and
nc.order_date between to_date ('||start_date||',''mm/dd/yyyy HH12:MI:SS AM'') and to_date ('||end_date||',''mm/dd/yyyy HH12:MI:SS AM'');
GROUP BY nc.min_id';
commit;
I know this has to be confusing but I'm sure there is a simple way to do what I want to have happen. If you can decipher all this, I would appreciate any help you can give.
Thank you.