2011-04-26 51 views
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()); 

我想插入到這個表中的對象的引用的嵌套表。我可以這樣做嗎?我將不得不放棄這張桌子嗎?如何插入REF表格?

+0

您希望指向哪個'artist_type'對象存儲? – 2011-04-26 13:40:33

+0

存在一個存儲artist_type的表,所有引用它們的對象都會存儲對這些對象的引用或引用表。 – Alex 2011-04-26 16:10:16

回答

1

您可以使用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> 
    ; 
-1
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; 

其餘的列將被正常插入並且上面的代碼被用於插入到嵌套表中。 如果你不明白,請告訴我。

+0

感謝您的迴應,但是您可以充實一點嗎?我不確定什麼意思是評論,什麼意思是由我填寫。 – Alex 2011-04-26 16:09:36