oracle存储过程游标循环
CREATE OR REPLACE PROCEDURE sp_sync_plan IS CURSOR C_EMP IS --声明显式游标 SELECT * FROM dc_check_todo; C_ROW C_EMP%ROWTYPE; --定义游标变量,该变量的类型为基于游标C_EMP的记录 BEGIN --For 循环 FOR C_ROW IN C_EMP LOOP DBMS_OUTPUT.PUT_LINE(C_ROW.todo_id || '--' ); END LOOP; --Fetch 循环 OPEN C_EMP;--必须要明确的打开和关闭游标 LOOP FETCH C_EMP INTO C_ROW; EXIT WHEN C_EMP%NOTFOUND; DBMS_OUTPUT.PUT_LINE(C_ROW.todo_id || '++' ); END LOOP; CLOSE C_EMP; --While 循环 OPEN C_EMP;--必须要明确的打开和关闭游标 FETCH C_EMP INTO C_ROW; WHILE C_EMP%FOUND LOOP DBMS_OUTPUT.PUT_LINE(C_ROW.todo_id || '**' ); FETCH C_EMP INTO C_ROW; END LOOP; CLOSE C_EMP; END sp_sync_plan;