Here :FOD and :TOD are considered as strings.
DBC.SYSEXECSQL doesnot replace :FOD and :TOD with their date values while running the Replace view query.
Now its working fine
REPLACE PROCEDURE DB1.TEMP_SP(#IN_DATE DATE)
BEGIN
DECLARE TOD CHAR(10);
DECLARE FOD CHAR(10);
SET FOD = CAST(CAST((#IN_DATE-(365*2)-1) AS FORMAT 'YYYY-MM-DD')AS CHAR(10));
SET TOD = CAST(CAST(#IN_DATE AS FORMAT 'YYYY-MM-DD') AS CHAR(10));
CALL DBC.SYSEXECSQL('REPLACE VIEW DB1.TEMP_VIEW
AS
SELECT
CAST(CAST(CAST( CALENDAR_DATE AS FORMAT ''YYYYMM'') AS CHAR(6)) AS INTEGER) AS YEAR_MONTH_ID,
RANK() OVER( ORDER BY YEAR_MONTH_ID DESC ) AS "PERIOD_RANK" FROM
SYS_CALENDAR.CALENDAR
WHERE CALENDAR_DATE BETWEEN '''||:FOD||''' AND '''||:TOD||'''
GROUP BY YEAR_MONTH_ID');
END;
Here :FOD and :TOD are considered as strings.
DBC.SYSEXECSQL doesnot replace :FOD and :TOD with their date values while running the Replace view query.
Now its working fine