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;
