Collections

The collection types TABLE and VARRAY allow you to declare index-by tables, nested tables, and variable-size arrays (varrays for short).

To reference an element, use standard subscripting syntax. For example, the following call references the fifth element in the nested table (of type Staff) returned by function new_hires:

DECLARE
TYPE Staff IS TABLE OF Employee;
staffer Employee;
FUNCTION new_hires (hiredate DATE) RETURN Staff IS
BEGIN … END;
BEGIN
staffer := new_hires(’10-NOV-98′)(5);

END;

Collections work like the arrays found in most third-generation programming languages. Also, collections can be passed as parameters. So, you can use them to move columns of data into and out of database tables or between client-side applications and stored subprograms.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: