Bypass “table or view does not exist” in package compilation

末鹿安然 提交于 2019-12-07 02:22:26

问题


There are two schemas in a Oracle database.

MYSCHEMA that is controlled by me.

OTHERSCHEMA that is not controlled by me.

I just know I can get result from select * from OTHERSCHEMA.OTHEROBJECT. However, OTHEROBJECT is a synonym.

In my package, I have a statement like

insert into MYSCHEMA.MYTABLE(COL1) select COL1 from OTHERSCHEMA.OTHEROBJECT;

But it gave me Table or view does not exist.

How can I solve or bypass this problem? Thanks!


回答1:


I assume you received the privilege to select from otherschema.otherobject by means of a role as opposted to a direct grant (such as grant all on otherschema.otherobject to myschema). If this is the case, the privileges within this role will not be used to determine what rights you have within a PL/SQL block.

See also How Roles Work in PL/SQL Blocks (Oracle Docu, where it says under Roles Used in Named Blocks with Definer's Rights:

All roles are disabled in any named PL/SQL block (stored procedure, function, or trigger) that executes with definer's rights. Roles are not used for privilege checking and you cannot set roles within a definer's rights procedure.)



来源:https://stackoverflow.com/questions/8599393/bypass-table-or-view-does-not-exist-in-package-compilation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!