为什么我直接select没问题,但封装到procedure中就提示找不到这张表呢?当前用户是有编译procedure的权限。
其中t1是hlisdata.t1的同义词SQL> create or replace procedure test is
2 begin
3 null;
4 end;
5 /Procedure createdSQL> create or replace procedure test is
2 a varchar2(30);
3 begin
4 select managecom into a from t1 where rownum=1;
5 end;
6 /Warning: Procedure created with compilation errorsSQL> show err;
Errors for PROCEDURE CIRCDATA.TEST:LINE/COL ERROR
-------- -----------------------------------------------
4/32 PL/SQL: ORA-00942: table or view does not exist
4/3 PL/SQL: SQL Statement ignoredSQL>
SQL> create or replace procedure test is
2 a varchar2(30);
3 begin
4 select managecom into a from hlisdata.t1 where rownum=1;
5 end;
6 /Warning: Procedure created with compilation errorsSQL> show err;
Errors for PROCEDURE CIRCDATA.TEST:LINE/COL ERROR
-------- -----------------------------------------------
4/41 PL/SQL: ORA-00942: table or view does not exist
4/3 PL/SQL: SQL Statement ignoredSQL> select managecom from hlisdata.t1 where rownum=1;MANAGECOM
----------
*****SQL>
其中t1是hlisdata.t1的同义词SQL> create or replace procedure test is
2 begin
3 null;
4 end;
5 /Procedure createdSQL> create or replace procedure test is
2 a varchar2(30);
3 begin
4 select managecom into a from t1 where rownum=1;
5 end;
6 /Warning: Procedure created with compilation errorsSQL> show err;
Errors for PROCEDURE CIRCDATA.TEST:LINE/COL ERROR
-------- -----------------------------------------------
4/32 PL/SQL: ORA-00942: table or view does not exist
4/3 PL/SQL: SQL Statement ignoredSQL>
SQL> create or replace procedure test is
2 a varchar2(30);
3 begin
4 select managecom into a from hlisdata.t1 where rownum=1;
5 end;
6 /Warning: Procedure created with compilation errorsSQL> show err;
Errors for PROCEDURE CIRCDATA.TEST:LINE/COL ERROR
-------- -----------------------------------------------
4/41 PL/SQL: ORA-00942: table or view does not exist
4/3 PL/SQL: SQL Statement ignoredSQL> select managecom from hlisdata.t1 where rownum=1;MANAGECOM
----------
*****SQL>
试着创建一个public的同义词试试。
这个地方的 a 是表吗?那就是a不存在