Okay, I'm new to writing in oracle, only VBA and SQL. Its normally pretty easy to define a variable and use it as a table to do a select from. I'm writing a procedure that will be used daily for 30 days, using a select from a table called nc_daily_new_customers. Once the month ends, I want it to select from a table called nc_monthly_new_customers. The next day it will then begin from nc_daily_new_customers again....
This is what I had:
create or replace procedure nc_new_customer_analysis(v_new_customer in varchar(20))
AS
begin
..
....
......
select blah
from &v_new_customer
where blah....
initially there is another procedure that checks the date to see if it is the first of the month. If it is, it passes the monthly table to select from, if not the default should be the daily table. Which leads to second question. I have the following to check for 1st of month, but it won't let me compile the procedure.
create or replace procedure "nc_start_new_customer_process"
is
begin
--****repopulate dupl_id's table
execute immediate 'cust_dupl_id';
--***********************************************************************************************
--Procedure to get daily new customers
--***********************************************************************************************
execute immediate 'nc_get_new_customers';
execute immediate 'nc_new_customer_analysis'
execute immediate 'nc_daily_stats';
execute immediate 'nc_archive_daily';
--***********************************************************************************************
--If the date is the first of the month,run daily_analysis, then run monthly analysis.
--***********************************************************************************************
case sysdate
when trunc(sysdate) then
execute immediate 'nc_monthly_new_customers',
execute immediate 'nc_new_customer_analysis(nc_monthly_new_customers)'
end;
I tried to use the search function here to find an answer, but couldn't find one. I apologize if this question has been asked before. But any help you can give would be extremely appreciated.
This is what I had:
create or replace procedure nc_new_customer_analysis(v_new_customer in varchar(20))
AS
begin
..
....
......
select blah
from &v_new_customer
where blah....
initially there is another procedure that checks the date to see if it is the first of the month. If it is, it passes the monthly table to select from, if not the default should be the daily table. Which leads to second question. I have the following to check for 1st of month, but it won't let me compile the procedure.
create or replace procedure "nc_start_new_customer_process"
is
begin
--****repopulate dupl_id's table
execute immediate 'cust_dupl_id';
--***********************************************************************************************
--Procedure to get daily new customers
--***********************************************************************************************
execute immediate 'nc_get_new_customers';
execute immediate 'nc_new_customer_analysis'
execute immediate 'nc_daily_stats';
execute immediate 'nc_archive_daily';
--***********************************************************************************************
--If the date is the first of the month,run daily_analysis, then run monthly analysis.
--***********************************************************************************************
case sysdate
when trunc(sysdate) then
execute immediate 'nc_monthly_new_customers',
execute immediate 'nc_new_customer_analysis(nc_monthly_new_customers)'
end;
I tried to use the search function here to find an answer, but couldn't find one. I apologize if this question has been asked before. But any help you can give would be extremely appreciated.