10g 包构造 - 限制引用

发布于 2024-12-06 20:33:45 字数 241 浏览 4 评论 0原文

我正在构建一个相当大的 Oracle 10g 包,其中充满了函数等。

问题是其中一些函数正在从其他函数正在创建的物化视图或表中提取信息。

有没有一种方法可以成功编译包,即使某些函数无法找到它们正在查找的信息(但是一旦创建了视图,这些函数就可以工作?)。

尝试: 我已经研究过PRAGMA RESTRICT_REFERENCES,但到目前为止还没有成功。我是否走在正确的轨道上,或者这根本不可能?

I am constructing a rather large Oracle 10g package full of functions etc.

The problem is some of these functions are pulling information from materilized view's or tables that other functions are creating.

Is there a way to successfully compile a package even though some of the functions cannot find the information they are looking for (But these functions will work once the views have been created?).

Attempts:
I have looked into PRAGMA RESTRICT_REFERENCES but have had no success so far. Am I even on the right track or is this not even possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉薄对峙 2024-12-13 20:33:45

您不能使用静态 SQL 来引用编译代码时不存在的对象。你对此无能为力。

您需要修改代码以使用动态 SQL 来引用在运行时创建的任何对象。您可能可以使用 EXECUTE IMMEDIATE,即,而

EXECUTE IMMEDIATE 
  'SELECT COUNT(*) FROM new_mv_name'
  INTO l_cnt;

不是

SELECT COUNT(*)
  INTO l_cnt
  FROM new_mv_name;

说,但是,我对涉及在运行时创建任何新表和物化视图的 PL/SQL 实现非常怀疑。这在 Oracle 中几乎总是一个错误。为什么需要在运行时创建新对象?

You cannot refer using static SQL to objects that do not exist when the code is compiled. There is nothing you can do about that.

You would need to modify your code to use dynamic SQL to refer to any object that is created at runtime. You can probably use EXECUTE IMMEDIATE, i.e.

EXECUTE IMMEDIATE 
  'SELECT COUNT(*) FROM new_mv_name'
  INTO l_cnt;

rather than

SELECT COUNT(*)
  INTO l_cnt
  FROM new_mv_name;

That being said, however, I would be extremely dubious about a PL/SQL implementation that involved creating any new tables and materialized views at runtime. That is almost always a mistake in Oracle. Why do you need to create new objects at runtime?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文