如何在 oracle11g 中定义引用该类型集合的类型?

发布于 2024-07-25 11:15:50 字数 168 浏览 1 评论 0原文

我想做这样的事情

create type Item as object (
    id number,
    subitems table of ref Item
)

,但当我尝试这样做时,oracle 抛出异常。 这可能吗?如果是的话,怎么办?

I want to do something like this

create type Item as object (
    id number,
    subitems table of ref Item
)

but oracle throws an exception when I try to do it. Is this possible, and if yes then how?

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

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

发布评论

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

评论(2

夏了南城 2024-08-01 11:15:50

Oracle 将不会编译您的定义,因为类型 Item 尚未编译。 你为什么不尝试一下:

编译这个:

CREATE OR REPLACE TYPE Item;

CREATE OR REPLACE TYPE items_table IS TABLE OF REF item;

然后尝试:

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

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
)
他是夢罘是命 2024-08-01 11:15:50

那就太好了不是吗! 你可以试试这个:

create type item_ids_t is table of number;

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

这意味着 subitems 只是一个 id 列表,然后将用于查找按 id 索引的表。

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.

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