I am connected into Oracle 10g database with user "user", when i run a select on DBA_ROLES it displays the result without any problem, but when the select is inside a procedure it returns the error ORA-00942: table or view does not exist
用户是否缺少某些特权?为什么可以执行 SELECT 但不能将其包含在过程中?
SQL> SELECT COUNT(*) FROM DBA_ROLES;
COUNT(*)
----------
18
SQL> CREATE OR REPLACE PROCEDURE tst_role IS
v VARCHAR2(100);
BEGIN
v := '';
FOR rec IN (SELECT ROLE FROM DBA_ROLES) LOOP
v := rec.role;
DBMS_OUTPUT.put_line(v);
END LOOP;
END;
/
Warning: Procedure created with compilation errors.
SQL> show errors
Errors for PROCEDURE TST_ROLE:
LINE/COL ERROR
-------- -----------------------------------------------------------------
5/13 PL/SQL: SQL Statement ignored
5/30 PL/SQL: ORA-00942: table or view does not exist
6/3 PL/SQL: Statement ignored
6/8 PLS-00364: loop index variable 'REC' use is invalid