Oracle循环中的EXIT、RETURN、CONTINUE解密
有时候编写Oracle中用游标等信息去循环处理逻辑的时候,对EXIT、RETURN、CONTINUE很容易搞混淆,网上搜了资料也不是很清楚,所以本人自己写了一小段代码测试了这三种用法。案例代码如下:
PROCEDURE P_TASK IS BEGIN FOR MY_CU IN (SELECT SPBH, SPMCH FROM FUCM) LOOP FOR MY IN (SELECT SPBH, SPMCH FROM FUCM) LOOP IF MY_CU.SPBH = 'AAA' THEN RETURN; --exit; --continue; ELSIF MY.SPBH = 'BBB' THEN INSERT INTO FUCM_JG (SPBH, SPMCH) VALUES ('123', '123'); ELSE INSERT INTO FUCM_JG (SPBH, SPMCH) VALUES ('222', '222'); END IF; INSERT INTO FUCM_JG (SPBH, SPMCH) VALUES ('333', '333'); END LOOP; END LOOP; INSERT INTO FUCM_JG (SPBH, SPMCH) VALUES ('444', '444'); END P_TASK;