[英]Getting PLS-00201 when trying to access another schema table
I want to clean some data on SCHEMA_ADM and SCHEMA_DAT tables, but, my procedure need to be stored on SCHEMA_DAT and will be called by SCHEMA_APP. 我想清除SCHEMA_ADM和SCHEMA_DAT表上的一些数据,但是,我的过程需要存储在SCHEMA_DAT上,并由SCHEMA_APP调用。 I did the procedure like this:
我做了这样的程序:
create or replace PACKAGE BODY "PKG_CLEANING_THE_MESS"
AS
PROCEDURE PRC_DELETE_DATA (some variables...)
AS
TYPE fooTableType
IS TABLE OF FOO_TABLE.ID%TYPE; --TABLE ON SCHEMA_DAT. Works fine!
fooTable fooTableType;
TYPE xyzTableType
IS TABLE OF XYZ_TABLE.ID%TYPE; --TABLE ON SCHEMA_ADM. The problem is here!!!
xyzTable xyzTableType;
...
END PRC_DELETE_DATA;
...
END PKG_CLEANING_THE_MESS;
When I try to compile that, give me 当我尝试编译时,给我
PLS-00201: identifier 'XYZ_TABLE' must be declared.
PLS-00201:必须声明标识符“ XYZ_TABLE”。
I tried "SCHEMA_ADM"."XYZ_TABLE" instead of just "XYZ_TABLE", but didn't works too. 我尝试了“ SCHEMA_ADM”。“ XYZ_TABLE”,而不仅仅是“ XYZ_TABLE”,但是也没有用。 The SCHEMA_DAT has a SIUD role to SCHEMA_ADM and a SYNONYM to XYZ_TABLE, but doing research I found that stored procedures can't use the grant of roles.
SCHEMA_DAT对SCHEMA_ADM具有SIUD角色,对XYZ_TABLE具有SYNONYM,但是进行研究后发现存储过程不能使用角色授予。 But I didn't found any way to give the grants on the PROCEDURE to compile without errors and to guarantee that SCHEMA_APP also can call the procedure.
但是我没有找到任何方法来授予PROCEDURE上的授权以进行编译而不会出错,并确保SCHEMA_APP也可以调用该过程。 Any help on that?
有什么帮助吗? Thanks!
谢谢!
EDIT: I found this similar question , asked 4 years ago, but without a conclusive answer :/ 编辑:我发现了类似的问题 ,问了4年前,但没有一个明确的答案:/
The checklist for this error should be something like: 此错误的清单应类似于:
XYZ_TABLE
exist? XYZ_TABLE
是否存在? (Did you spell it right? Is it actually named in double-quotes as something like "xyz_table"
or "XYZ Table"
?) "xyz_table"
或"XYZ Table"
吗?) SCHEMA_ADM
? SCHEMA_ADM
? SCHEMA_DAT
? SCHEMA_DAT
? X
for table Y
, but the code refers to Y
.) Y
可能有同义词X
,但代码引用了Y
) SCHEMA_DAT.XYZ_TABLE
? SCHEMA_DAT.XYZ_TABLE
? SCHEMA_DAT
)? SCHEMA_DAT
)? This could create a naming conflict where the compiler finds the package instead of the schema, and then looks in that for something called XYZ_TABLE
. XYZ_TABLE
。 Your requirements may vary, but it's usually better to create a synonym than to hardcode the schema name (less to type, more flexibility if things change), and private synonyms are preferable to public synonyms (security, as they don't broadcast your schema structure, and more flexible in case you want to direct different users to different objects, or add another schema later with different requirements). 您的要求可能会有所不同,但是创建同义词通常比对模式名称进行硬编码(键入少,如果情况发生变化,灵活性更大)更好,并且私有同义词比公共同义词更可取(安全性,因为它们不会广播您的模式)结构,如果您想将不同的用户定向到不同的对象,或者以后添加具有不同要求的另一个架构,则更加灵活。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.