The following Code gets two dates and sets the firstmonth date to the 16 of the month and the lastmonths date to the 15 of the month. Then it passes these dates into another procedure. That is where i think im getting the error (EXECUTE IMMEDIATE). Thanks for any help!
CREATE PROCEDURE PROCEDUREDATE1()
select LastMonth -16 days into case1 from BusinessDate where date_type='CQTR';
select LastMonth -15 days into case2 from BusinessDate where date_type='CQTR';
select LastMonth -14 days into case3 from BusinessDate where date_type='CQTR';
select LastMonth -13 days into case4 from BusinessDate where date_type='CQTR';
select day(LastMonth)into test from BusinessDate where date_type='CQTR';
when test=31 THEN case1
when test=30 THEN case2
when test=29 THEN case3
select FirstMonth +15 days into BeginDate from BusinessDate where date_type ='CQTR';
SET SQLSTMT = 'call ProcedureDate2(?,?,?,BeginDate, EndDate,.97)';
execute immediate SQLSTMT;
Run ProcedureDate1 ()
PROCEDUREDATE1- Run started.
Data returned in result sets is limited to the first 50 rows.
Data returned in result set columns is limited to the first 100 bytes or characters.
PROCEDUREDATE1- Calling the stored procedure.
PROCEDUREDATE1- Exception occurred while running:
A database manager error occurred.SQLCODE: -206, SQLSTATE: 42703 - "BeginDate" is not valid in the context where it is used.. SQLCODE=-206, SQLSTATE=42703, DRIVER=3.53.71
PROCEDUREDATE1- Roll back completed successfully.
PROCEDUREDATE1- Run failed.