How can I define a type in oracle11g that references a collection of that type?

牧云@^-^@ 提交于 2019-12-01 20:02:56

Oracle will not compile your definition because the type Item hasn't been compiled yet. Why dont you give this a try:

Compile this:

CREATE OR REPLACE TYPE Item;

CREATE OR REPLACE TYPE items_table IS TABLE OF REF item;

and then try:

CREATE OR REPLACE TYPE item AS OBJECT (
   id number,
   subitems items_table
)

That would be nice wouldn't it! You could try this:

create type item_ids_t is table of number;

create type Item as object (
   id number,
   subitems item_ids_t);

Which means that subitems is just a list of ids, which would then be used to look up a table indexed by id.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!