当我尝试在Oracle数据库中编译我的项目时,我有一个问题.为了使其更简单,我有三个对象:2个包(UTILS和TYPES)和1个视图(VIEW).
软件包UTILS正在使用包TYPES中定义的类型. TYPES包使用VIEW作为其中一种类型的基础.而VIEW正在使用UTILS包中的函数.当我尝试对这些对象之一进行一些更改时,我无法编译,因为一切都处于无效状态.所以创建一些对象依赖循环.
请帮我解决这个问题.
例如,有没有编译下面的代码?每个对象都是单独的语法正确的,但是如何将它们全部编译在一起?
create or replace package my_types is type type1 is table of number; type type2 is table of my_view%rowtype; end; / create or replace package my_utils is function get_1 return number; procedure do_something(parameter my_types.type2); end; / create or replace package body my_utils is function get_1 return number is begin return 1; end; procedure do_something(parameter my_types.type2) is begin null; end; end; / create or replace force view my_view as select * from dual where 1 = my_utils.get_1(); exec dbms_utility.compile_schema(user,false); select object_name from user_objects where status <> 'VALID';
如果您不想/不能拆分您的包或视图,您可以随时创建您的视图的虚拟版本,编译包,然后创建“真实”视图:
create or replace package my_types is type type1 is table of number; type type2 is table of my_view%rowtype; end; / create or replace package my_utils is function get_1 return number; procedure do_something(parameter my_types.type2); end; / create or replace package body my_utils is function get_1 return number is begin return 1; end; procedure do_something(parameter my_types.type2) is begin null; end; end; / create or replace force view my_view as select * from dual; exec dbms_utility.compile_schema(user,false); create or replace force view my_view as select * from dual where 1 = my_utils.get_1(); select object_name from user_objects where status <> 'VALID';