开发者

10g Package Construction - Restricting 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?


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜