Select a collection into a collection variable

After you declare a collection variable, you can fetch a collection into it. To fetch a collection into a collection variable, enter a SELECT INTO statement that selects the collection column from the database into the collection variable you have named.

For example, to select the collection stored in one row of the primes column of numbers, add a SELECT statement, such as the one that the following figure shows, to your SPL routine.
Figure 1: Add a SELECT statement to select the collection stored in one row.
SELECT primes INTO p_coll FROM numbers
   WHERE id = 220;

The WHERE clause in the SELECT statement specifies that you want to select the collection stored in just one row of numbers. The statement places the collection into the collection variable p_coll, which Declare a collection variable. declares.

The variable p_coll now holds a collection from the primes column, which could contain the value SET {5,7,31,19,13}.