oracle 如何从有效包中获取“ORA-00904:: 无效标识符”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4722060/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 22:29:29  来源:igfitidea点击:

How can I get "ORA-00904: : invalid identifier" from a valid package?

oracleoracle9iora-00904

提问by jva

I have a procedure that is valid and has in it an insert..select statement. Now there is a case where execution of this procedure produces "ORA-00904: : invalid identifier" error from this statement. How is that even theoretically possible? There are no triggers or dynamic SQL.

我有一个有效的过程,其中包含一个 insert..select 语句。现在有一种情况,该过程的执行会从该语句中产生“ORA-00904:: 无效标识符”错误。这在理论上怎么可能?没有触发器或动态 SQL。

Also, the ORA-00904 text in sqlerrm is without pointer to any specific identifier that Oracle considers invalid.

此外,sqlerrm 中的 ORA-00904 文本没有指向 Oracle 认为无效的任何特定标识符的指针。

Oracle version 9.2.0.8

甲骨文版本 9.2.0.8

edit2:

编辑2:

Turns out there was a problem with a function that was called from within that select (replaced it with constants and everything worked). Probably that was the reason that ORA-00904 did not give an identifier. Still, the question remains - how can that be that precompiled code with no dynamic sql gives this error?

结果发现从该 select 中调用的函数存在问题(用常量替换它并且一切正常)。可能这就是 ORA-00904 没有给出标识符的原因。尽管如此,问题仍然存在 - 没有动态 sql 的预编译代码怎么会给出这个错误?

回答by Jens Schauder

I think this kind of error might happen when you access a package where the package is valid but the body needs compilation and throws the exception.

我认为当您访问包有效但主体需要编译并抛出异常的包时,可能会发生这种错误。

Another reason might be code with authid current_user it runs with the privileges of the current user (not as normal with the privileges of the owning user). Such a procedure might fail when called with one and succeed when executed with another user.

另一个原因可能是带有 authid current_user 的代码,它以当前用户的权限运行(与拥有用户的权限不同)。这样的过程在用一个用户调用时可能会失败,而在用另一个用户执行时可能会成功。

回答by NL3294

Since you already found the solution, this wasn't your problem. But I wanted to add a note, that you get this error if the package function has a body, but there's no function signature in the Spec sheet.

由于您已经找到了解决方案,因此这不是您的问题。但是我想添加一个注释,如果包函数有一个主体,但规范表中没有函数签名,则会出现此错误。