您的位置:程序门 -> db2 -> 基础类



存储过程在aix的db2上能成功运行,而在windows的db2要报错!!!!!!


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


存储过程在aix的db2上能成功运行,而在windows的db2要报错!!!!!!
发表于:2007-06-12 14:26:39 楼主
declare   cursor1   cursor   with   hold   for  
select   *   from   a;

insert   int   a   (col1,col2)   value   ( 'a ', 'd ');

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;
end   loop   loop_1;

close   cursor1;      

在aix的db2上能成功运行,但在windows的db2上报508错,为什么啊??????
发表于:2007-06-17 22:50:351楼 得分:0
假设楼主的变量都已定义。
value   应该为   values
对于指定的游标,不允许   update   或   delete。  

好奇楼主如何在aix上通过的。
发表于: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


快速检索

最新资讯
热门点击