-- 첫번째 예제
CREATE OR REPLACE PROCEDURE SP_MYCURSOR
IS
  V_OBJ_UID		  	  		TMP_OBJECT.OBJ_UID%TYPE;
  V_GIS_CODE		  	  	TMP_OBJECT.GIS_CODE%TYPE;
  V_OBJ_DETAILGISCODE		TMP_OBJECT.OBJ_DETAILGISCODE%TYPE;

  CURSOR MYCURSOR
  IS
  SELECT OBJ_UID, GIS_CODE, OBJ_DETAILGISCODE FROM TMP_OBJECT;

BEGIN
	 OPEN MYCURSOR;

	 LOOP

	 	 FETCH MYCURSOR INTO V_OBJ_UID, V_GIS_CODE, V_OBJ_DETAILGISCODE;

	 	 EXIT WHEN MYCURSOR%NOTFOUND;

	 	 UPDATE ND_OBJECT SET GIS_CODE = V_GIS_CODE, OBJ_DETAILGISCODE = V_OBJ_DETAILGISCODE WHERE OBJ_UID = V_OBJ_UID;

	 END LOOP;

	 CLOSE MYCURSOR;
END SP_MYCURSOR;
/

-- 두번째 예제
CREATE OR REPLACE PROCEDURE MYCursorProc
IS
  V_BOD_UID         ND_Board.BOD_UID%TYPE;
  V_BOD_TITLE       ND_Board.BOD_TITLE%TYPE;
  V_BOD_EMAIL       ND_Board.BOD_EMAIL%TYPE;
  V_BOD_READCNT     ND_Board.BOD_READCNT%TYPE;
  V_BOD_OPINIONCNT  ND_Board.BOD_OPINIONCNT%TYPE;
  V_BOD_TAG         ND_Board.BOD_TAG%TYPE;
  V_BOD_OPEN        ND_Board.BOD_OPEN%TYPE;
  V_BOD_STATE       ND_Board.BOD_STATE%TYPE;
  V_BOD_REF         ND_Board.BOD_REF%TYPE;
  V_BOD_LEVEL       ND_Board.BOD_LEVEL%TYPE;
  V_BOD_ORDER       ND_Board.BOD_ORDER%TYPE;
  V_BOD_REPLYCNT    ND_Board.BOD_REPLYCNT%TYPE;
  V_BOD_PARENTUID   ND_Board.BOD_PARENTUID%TYPE;
  V_MNU_UID         ND_MenuInfo.MNU_UID%TYPE;

  CURSOR myCursor IS
  SELECT *
  FROM ND_Board
  WHERE MNU_UID=112 AND BOD_UID BETWEEN 2373 and 2452
  ORDER BY BOD_TITLE DESC;

  BEGIN
  	   OPEN myCursor;
	   LOOP
	   	   FETCH myCursor
		   INTO V_BOD_UID, V_BOD_TITLE, V_BOD_EMAIL, V_BOD_READCNT, V_BOD_OPINIONCNT, V_BOD_TAG, V_BOD_OPEN, V_BOD_STATE, V_BOD_REF, V_BOD_LEVEL,
		   		V_BOD_ORDER, V_BOD_REPLYCNT, V_BOD_PARENTUID, V_MNU_UID;

		   EXIT WHEN myCursor%NOTFOUND;

		   INSERT INTO ND_Board
		   VALUES (SEQ_BOD_UID.NEXTVAL, V_BOD_TITLE, V_BOD_EMAIL, V_BOD_READCNT, V_BOD_OPINIONCNT, V_BOD_TAG, V_BOD_OPEN, V_BOD_STATE, SEQ_BOD_UID.CURRVAL, V_BOD_LEVEL,
		   		  V_BOD_ORDER, V_BOD_REPLYCNT, V_BOD_PARENTUID, V_MNU_UID);

		   UPDATE ND_BoardContent SET BOD_UID = SEQ_BOD_UID.CURRVAL
		   WHERE BOD_UID = V_BOD_UID;

		   UPDATE ND_BoardData SET BOD_UID = SEQ_BOD_UID.CURRVAL
		   WHERE BOD_UID = V_BOD_UID;

	   END LOOP;
	   CLOSE myCursor;
END MYCursorProc;
/