How do I insert into a table of REF's?
CREATE TYPE artist_table_type AS TABLE OF REF artist_type;
/
INSERT INTO track_table VALUES (
1,
'test title', 开发者_StackOverflow社区
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?
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>
;
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.
精彩评论