如何插入 REF 表?

发布于 2024-11-03 05:02:39 字数 668 浏览 0 评论 0原文

CREATE TYPE artist_table_type AS TABLE OF REF artist_type;
/                                                         

INSERT INTO track_table VALUES (                              
   1,                                                     
   'test title',                                          
   123,                                                   
   to_date('12-09-1989', 'dd-mm-yyyy'),                   
   artist_table_type(                                     
            -- What goes here???
   ),                                                     
   artist_table_type());  

我想在此表中插入对象引用的嵌套表。我可以这样做吗?我必须取消这张桌子的嵌套吗?

CREATE TYPE artist_table_type AS TABLE OF REF artist_type;
/                                                         

INSERT INTO track_table VALUES (                              
   1,                                                     
   'test title',                                          
   123,                                                   
   to_date('12-09-1989', 'dd-mm-yyyy'),                   
   artist_table_type(                                     
            -- What goes here???
   ),                                                     
   artist_table_type());  

I want to insert into this table a nested table of references to objects. Can I do this? Am I going to have to un-nest this table?

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

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

发布评论

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

评论(2

可爱暴击 2024-11-10 05:02:39

您可以使用 COLLECT 和 CAST 函数在 SQL 中创建嵌套表。例如,如果您想根据某些条件从其他表中选择艺术家对象,我相信这应该可行:

INSERT INTO track_table
  SELECT
   1,
   'test title',
   123,
   to_date('12-09-1989', 'dd-mm-yyyy'),
   CAST(COLLECT(REF(artists)) AS artist_table_type)
   artist_table_type()
  FROM
   artists
  WHERE <whatever the condition is for selecting the appropriate artists>
  ;

You can create a nested table within SQL by using the COLLECT and CAST functions. For instance, if you want to select artist objects from some other table based on some condition, I believe this should work:

INSERT INTO track_table
  SELECT
   1,
   'test title',
   123,
   to_date('12-09-1989', 'dd-mm-yyyy'),
   CAST(COLLECT(REF(artists)) AS artist_table_type)
   artist_table_type()
  FROM
   artists
  WHERE <whatever the condition is for selecting the appropriate artists>
  ;
只是我以为 2024-11-10 05:02:39
INSERT INTO TABLE(this table is syntax dont think its name of the table..)

(SELECT t.nested_tbl_colm 
(nested_tbl_colm is nested table) 

FROM table_name t 
(table_name is the normal table whose one or more column is nested table here its nested_tbl_colm)  

WHERE t.tbl_colm= any input or conditions)

VALUES
(value to be inserted);

COMMIT;

该列的其余部分将正常插入,上面的代码用于插入嵌套表。
如果您不明白,请告诉我。

INSERT INTO TABLE(this table is syntax dont think its name of the table..)

(SELECT t.nested_tbl_colm 
(nested_tbl_colm is nested table) 

FROM table_name t 
(table_name is the normal table whose one or more column is nested table here its nested_tbl_colm)  

WHERE t.tbl_colm= any input or conditions)

VALUES
(value to be inserted);

COMMIT;

Rest of the column will be inserted normally and the above code is used to insert into nested table.
Let me know if you didn't understand.

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