我已将存储过程编写为
CREATE OR REPLACE PROC1()
DECLARE VAR1 INT;
DECLARE VAR2 INT;
DECLARE TEXT VARCHAR(1000);
DECLARE exitcode INTEGER DEFAULT 0;
DECLARE SQLCODE INTEGER DEFAULT 0;
DECLARE CUR1 CURSOR WITH HOLD for STMT1 ;
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET exitcode = 1;
SET TEXT= (-----);
PREPARE STMT1 FROM TEXT;
open cur1;
fetch from cur1 into var1,var2;
while(sqlcode =0)
do
--
--
CALL SYSPROC.ADMIN_CMD('REORG TABLE emp1 ');
set exit code = 0;
fetch from cur1 into var1,var2;
IF (exitcode = 1)
THEN
LEAVE wloop;
END IF;
end while;
close cur1;
我的问题是,即使我将光标声明为WITH HOLD选项,在第一次获取光标后关闭&抛出-501错误。如果我从循环中删除REORG语句。然后光标正常工作,获取所有行。即使我在循环中使用REORG语句,也有人可以通过电话让我保持光标打开。
提前致谢