Syntax

Database
Enthusiast

Syntax

I am getting the following error : SPL1027:E(L7), Missing/Invalid SQL statement'E(3706):Syntax error: expected something between the word 'StartDate' and the 'DATE' keyword.'. Looks like a syntax error where i am declaring the variable StartDate .

Please advice. Thanks.

CREATE MULTISET VOLATILE TABLE TEMP2

AS

(

SELECT * FROM DDWV21R.CC_HIER_CURR WHERE CAL_DT = '2014/11/22'


WITH DATA AND STATS

PRIMARY INDEX (CAL_DT)

ON COMMIT PRESERVE ROWS; 

-------------------------------------------------------------------------------------------------------------

REPLACE PROCEDURE DL_AC_LEADERSHIP.sp_TEMP2()

DYNAMIC RESULT SETS 1

BEGIN

DECLARE C CURSOR WITH RETURN ONLY FOR

SELECT * FROM Temp2 ;

DECLARE StartDate DATE ;

CREATE MULTISET VOLATILE TABLE TEMP2

AS

(

SELECT * FROM DDWV21R.CC_HIER_CURR WHERE CAL_DT =StartDate


WITH DATA AND STATS

PRIMARY INDEX (CAL_DT)

ON COMMIT PRESERVE ROWS; 

OPEN C;

END;

select * from temp2;