Domanda

I am new to PL/SQL and experimenting with CURSOR. I desire to verify an insertion procedure so I wrote another procedure to do so.

CREATE OR REPLACE PROCEDURE verify_insert

IS

   CURSOR map_cur IS

      SELECT Page_ID_NBR, Page_Type, Page_Dcpn FROM SSC_Page_Map;

      map_rec map_cur%ROWTYPE;

BEGIN

   OPEN map_cur;

   FOR map_rec in map_cur

   LOOP

      DBMS_OUTPUT.PUT_LINE('ID: ' || map_cur.Page_ID_NBR || ' ' || 'Type' ||  map_cur.Page_Type || ' ' || 'Description' || map_cur.Page_Dcpn);   

   END LOOP;

   CLOSE map_cur;

END;

SHOW ERRORS PROCEDURE verify_insert;

I am getting the following message

[Warning] ORA-24344: success with compilation error
19/44   PLS-00225: subprogram or cursor 'MAP_CUR' reference is out of scope
19/5    PL/SQL: Statement ignored
(47: 0): Warning: compiled but with compilation errors

I also see

Errors for PROCEDURE VERIFY_INSERT

LINE/COL ERROR                                                            
-------- -----------------------------------------------------------------
19/44    PLS-00225: subprogram or cursor 'MAP_CUR' reference is out of sco


19/5     PL/SQL: Statement ignored                                        

As I wrote, I am new and trying to cobble together knowledge of PL/SQL from Oracle PL/SQL Programming (Feuerstein) and the net. Coming together but not as fast as I want.

È stato utile?

Soluzione

Your loop is fetching a row from the cursor into the record type. Inside the loop, you'd want to read the data from the record type. In your dbms_output.put_line call, you'd want to reference the record not the cursor.

DBMS_OUTPUT.PUT_LINE('ID: ' || map_rec.Page_ID_NBR || 
              ' ' || 'Type' || map_rec.Page_Type || 
              ' ' || 'Description' || map_rec.Page_Dcpn);  
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top