| 发表于:2007-07-23 10:56:132楼 得分:0 |
下面是我写的测试的存储过程,在window版本的db2上报508错,在aix的db2上能执行通过 create procedure crns.p_git_2( out out_sqlcode integer, out out_msg varchar(256) ) result sets 1 p1: begin declare sqlcode integer default 0; declare col1 varchar(10); declare col2 varchar(10); declare continue handler for not found, sqlexception, sqlwarning set out_sqlcode = sqlcode; insert into a (col1,col2) values ( 'a ', 'd '); if out_sqlcode <> 0 and out_sqlcode <> 100 then set out_msg = 'insert into t_panelbankdeal ' ¦ ¦char(out_sqlcode); goto error_return; end if; p2: begin declare cursor1 cursor with hold for select * from a for update; open cursor1; loop_1: loop fetch cursor1 into col1,col2; if sqlcode=100 then leave loop_1; end if; update a set col1 = 'dd ' where current of cursor1; if out_sqlcode <> 0 and out_sqlcode <> 100 then set out_msg = '计算利差 ' ¦ ¦char(out_sqlcode); goto error_return; end if; end loop loop_1; close cursor1; end p2; error_return: rollback; return out_sqlcode; end p1 | | |
|