Nested Table Example

TYPE card_table IS TABLE OF VARCHAR2(5 CHAR);
— Declare a nested table with null values.
cards CARD_TABLE := card_table(NULL,NULL,NULL);
BEGIN
— Print initialized null values.
dbms_output.put_line(‘Nested table initialized as null values.’);
dbms_output.put_line(‘——————–––––––––––––––––––––’);
FOR i IN 1..3 LOOP
dbms_output.put (‘Cards Varray [‘||i||’] ‘);
dbms_output.put_line(‘[‘||cards(i)||’]’);
END LOOP;
–– Assign values to subscripted members of the nested table.

cards(1) := ‘Ace’;
cards(2) := ‘Two’;
cards(3) := ‘Three’;
–– Print initialized null values.
dbms_output.put (CHR(10)); — Visual line break.
dbms_output.put_line(‘Nested table initialized as 11, 12 and 13.’);
dbms_output.put_line(‘———————–––––––––––––––––––––’);
FOR i IN 1..3 LOOP
dbms_output.put_line(‘Cards [‘||i||’] ‘||'[‘||cards(i)||’]’);
END LOOP;
END;
/

Advertisements

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