Mus*_*shy 2 toad plsql oracle11g
我是PL/SQL新手并尝试使用CURSOR.我想验证一个插入过程,所以我写了另一个程序来这样做.
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;
Run Code Online (Sandbox Code Playgroud)
我收到以下消息
[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
Run Code Online (Sandbox Code Playgroud)
我也看到了
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
Run Code Online (Sandbox Code Playgroud)
正如我写的那样,我是新手,并试图将网络上的PL/SQL知识拼凑起来Oracle PL/SQL Programming (Feuerstein).聚在一起,但没有我想要的那么快.
你的循环从光标中取出一行到记录类型.在循环内部,您需要从记录类型中读取数据.在您的dbms_output.put_line通话中,您需要引用记录而不是光标.
DBMS_OUTPUT.PUT_LINE('ID: ' || map_rec.Page_ID_NBR ||
' ' || 'Type' || map_rec.Page_Type ||
' ' || 'Description' || map_rec.Page_Dcpn);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12858 次 |
| 最近记录: |