请教下db2 存储过程 变量声明位置
答案:2 悬赏:30 手机版
解决时间 2021-04-05 13:50
- 提问者网友:别再叽里呱啦
- 2021-04-04 13:34
当我把变量declare在其他ddl语句之后,在导入存储过程的时候,就出现:"后面找到异常标记"END-OF-STATEMENT"。预期标记可能包括:"
"
如果放在前面就没问题
问下db2的变量声明必须这样么,因为我有嵌套的declare continue handler for data not found使用
最佳答案
- 五星知识达人网友:动情书生
- 2021-04-04 15:11
是的,你必须在第一次使用前声明并且赋值,否则就会报错,很多语言都是这样的,你在一段java代码中一样要在使用前声明切初始化的。
全部回答
- 1楼网友:从此江山别
- 2021-04-04 16:23
把所有变量声明都放在开头,如:
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;
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯