create or replace function gen.sample_func(owner varchar2) return varchar2
as
data_t varchar2(10);
cursor cur is select data_type from SYS.DBA_TAB_COLUMNS;
begin
open cur;
dbms_output.put_line('Done');
close cur;
return data_t;
end sample_func;
Run Code Online (Sandbox Code Playgroud)
在编译上面的函数时,我得到以下错误
Warning: compiled but with compilation errors
Errors for FUNCTION sample_func
LINE/COL
--------------------------------------------------------------------------------
ERROR
--------------------------------------------------------------------------------
4/8
PLS-00201: identifier 'DBA_TAB_COLUMNS' must be declared
4/8
PL/SQL: Item ignored
7/15
PLS-00320: the declaration of the type of this expression is incomplete or malfo
rmed
7/8
PL/SQL: Statement ignored
Run Code Online (Sandbox Code Playgroud)
当我select在游标中单独执行语句时,我没有收到此错误.请帮我解决这个问题.
在定义者权限存储过程(例如您正在创建的过程)中,只有在解析对象名称时才会考虑直接授予过程所有者的权限.不考虑通过角色授予的权限.我打赌你的程序的所有者已被授予DBA_TAB_COLUMNS通过角色而不是通过直接授权访问视图的权限.您需要让DBA DBA_TAB_COLUMNS直接向拥有您的过程的用户授予访问权限.
您可以快速测试这是否实际上是您遇到的问题.在SQL*Plus中,输入命令
SQL> set role none;
Run Code Online (Sandbox Code Playgroud)
然后运行SELECT语句.如果您获得相同的权限错误,则rpoblem是您通过角色获得授权.禁用角色意味着您的交互式会话运行时具有与存储过程一起运行的相同权限.
| 归档时间: |
|
| 查看次数: |
2030 次 |
| 最近记录: |