Home | Previous Page | Next Page   Object-Relational Databases > Creating and Using User-Defined Casts in Dynamic Server > Casting Collection Data Types >

Converting Relational Data to a MULTISET Collection

When you have data from a relational table you can use a collection subquery to cast a row value to a MULTISET collection. Suppose you create the following tables:

CREATE TABLE tab_a ( a_col INTEGER);
CREATE TABLE tab_b (ms_col MULTISET(ROW(a INT) NOT NULL) );

The following example shows how you might use a collection subquery to convert rows of INT values from the tab_a table to a MULTISET collection. All rows from tab_a are converted to a MULTISET collection and inserted into the tab_b table.

INSERT INTO tab_b VALUES (
   (MULTISET (SELECT a_col FROM tab_a)))
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]