当我把变量declare在其他ddl语句之后,在导入存储过程的时候,就出现:"后面找到异常标记"END-OF-STATEMENT"。预期标记可能包括:"
"
如果放在前面就没问题
问下db2的变量声明必须这样么,因为我有嵌套的declare continue handler for data not found使用
把所有变量声明都放在开头,如:
create procedure "aml"."czjy053"
(in "datadate" varchar(8)
)
begin
declare period varchar(20);--回顾周期
declare times varchar(20);--周期内发生次数
declare sum_crat varchar(20);--周期内金额总额
set period = (select value from context_variable where type = 'czjy053' and key = 'period');
set times = (select value from context_variable where type = 'czjy053' and key = 'times');
set sum_crat = (select value from context_variable where type = 'czjy053' and key = 'sum_crat');
delete from t_fxqnbs where remark1 = 'czjy053';
insert into t_fxqnbs select * from fxqtrade_cc trans,(select csnm,tcac from fxqtrade_cc where tstm>to_char(to_date(datadate,'yyyymmdd')-period days,'yyyymmdd') and opcustomtype in (select key_value from fxqparam where key ='opcustomtype_cc') group by csnm,tcac having count(*)>=9 and sum(crat) >=1800000) a
where trans.tstm = datadate
and trans.csnm = a.csnm
and trans.tcac = a.tcac;
end;