Oracle自依赖类型声明

时间:2018-09-11 13:34:28

标签: oracle

我想像下面这样在Oracle中创建自定义类型。.谁能告诉我如何实现这一目标。

CREATE OR REPLACE TYPE Items_Type FORCE IS OBJECT ( "S.No" VARCHAR2(500) NULL , sub_list "Items_table" NULL  ) NOT FINAL;

CREATE OR REPLACE TYPE Items_table IS TABLE OF REF Items_Type;

1 个答案:

答案 0 :(得分:0)

好吧,您可以再次重复第一个CREATE OR REPLACE TYPE,因为它在第一次执行时会失败。看看:

SQL> -- statement A
SQL> create or replace type items_type force is object
  2    (sno      varchar2(500) null ,
  3     sub_list items_table   null
  4    ) not final;
  5  /

Warning: Type created with compilation errors.

SQL> show err
Errors for TYPE ITEMS_TYPE:

LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0      PL/SQL: Compilation unit analysis terminated
3/13     PLS-00201: identifier 'ITEMS_TABLE' must be declared
SQL>
SQL> -- statement B
SQL> create or replace type items_table is table of ref items_type;
  2  /

Type created.

SQL> -- statement A, repeated
SQL> create or replace type items_type force is object
  2    (sno      varchar2(500) null ,
  3     sub_list items_table   null
  4    ) not final;
  5  /

Type created.

SQL>