CREATE PROCEDURE CRNS.P_PANELBANKDEAL
(IN IN_STARTTIME DATE,
IN IN_ENDTIME DATE
)
RESULT SETS 1
P1: BEGIN
declare SQLCODE integer default 0;
delete from T_PANELBANKDEAL
where dealdate between IN_STARTTIME and IN_ENDTIME;
insert into CRNS.T_PANELBANKDEAL
select* from V_PANELBANKDEAL_GIT order by DEALDATE;
DECLARE cursor1 CURSOR WITH hold FOR
select dealdate,bankcode,vrtid,TL,dir,ir from T_PANELBANKDEAL
where dealdate between IN_STARTTIME and IN_ENDTIME for update;
OPEN cursor1;
END P1
编译通不过,是不是declare语句只能写在最前面?但我必须要先insert之后才能定义update类型的游标,请问如何解决????
------解决方案--------------------------------------------------------
DECLARE cursor1 CURSOR WITH hold FOR ...
这部分应该写在前面,这是DB2约定的