在Cursor上使用条件,当它在DB2中的Emty(NOT FOUND)时

时间:2015-09-17 08:26:21

标签: cursor db2

我想像在Oracle中那样在Cursor上创建一个条件(IF cur%NOTFOUND THEN ..)。 我尝试在DB2中使用此代码:

afl-fuzz -i testcases/ -o findings/ tcpdump-4.6.2/tcpdump -nr @@

我收到了这个错误:

CREATE OR REPLACE PROCEDURE PROC_SAMPLE1()
BEGIN ATOMIC
DECLARE V_DESCRIPTION_1 VARCHAR(4000);
DECLARE V_DESCRIPTION_2 VARCHAR(4000);
DECLARE sys cursor FOR select DESCRIPTION_1, DESCRIPTION_2 from DESC;
open sys;
TEST:
LOOP 
IF (sys IS NOT FOUND) THEN // **error in this line**
LEAVE TEST;
END IF;
fetch FROM sys INTO V_DESCRIPTION_1,V_DESCRIPTION_2;
-- other treatments
    END IF;
END LOOP TEST;
close sys;
END;

1 个答案:

答案 0 :(得分:0)

我用Select语句替换了游标,我的问题解决了:

CREATE OR REPLACE PROCEDURE PROC_SAMPLE1()
BEGIN ATOMIC
DECLARE V_DESCRIPTION_1 VARCHAR(4000);
DECLARE V_DESCRIPTION_2 VARCHAR(4000);

FOR v_row AS select DESCRIPTION_1, DESCRIPTION_2 from DESC DO   
-- other treatments

END FOR;

END;