12c – Nested tables vs Associative arrays

This was going to the be the immediate follow up to my previous post, but 12.1.0.2 came out and I got all excited about that and forgot to post this one :-)

Anyway, the previous post showed how easy it is to convert between nested tables and associative arrays.  The nice thing in 12c is that this is no longer needed – you can query the associative arrays directly

SQL> create or replace package PKG as
  2
  3    type num_list is table of number index by pls_integer;
  4
  5  end;
  6  /

Package created.

SQL>
SQL> declare
  2    v pkg.num_list;
  3  begin
  4    v(1) := 10;
  5    v(2) := 20;
  6
  7    for i in ( select * from table(v) ) loop
  8      dbms_output.put_line(i.column_value);
  9    end loop;
 10  end;
 11  /
10
20

PL/SQL procedure successfully completed.

One thought on “12c – Nested tables vs Associative arrays

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