Learning is not a spectator sport

August 9, 2014

12c – Nested tables vs Associative arrays

Filed under: Uncategorized — connormcdonald @ 9:31 am

This was going to the be the immediate follow up to my previous post, but 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
  3    type num_list is table of number index by pls_integer;
  5  end;
  6  /

Package created.

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

PL/SQL procedure successfully completed.

1 Comment »

  1. […] The ability of using SQL to operate on Associative Arrays or PL/SQL tables as they were known when I started working as a Database Developer is one of my favourite new features of 12c. I wasn’t aware of it until I read the post by Connor Mcdonald. […]

    Pingback by Using SQL with Associative Arrays of records in Oracle 12c | OracleFrontovik — August 13, 2014 @ 4:54 am

RSS feed for comments on this post. TrackBack URI

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

The WordPress Classic Theme. Blog at WordPress.com.


Get every new post delivered to your Inbox.

Join 94 other followers

%d bloggers like this: