Starting with 12.1, you can now use the TABLE operator with associative arrays whose types are defined in a package specification. One really sweet application of this feature is to order the contents of your collection. Let's take a look Suppose I create these database objects: CREATE TABLE plch_employees ( employee_id INTEGER PRIMARY KEY, last_name VARCHAR2 (100) UNIQUE, salary NUMBER ) / BEGIN INSERT INTO plch_employees VALUES (100, 'Apramy', 1000); INSERT INTO plch_employees VALUES (175, 'Shipo', 2500); INSERT INTO plch_employees VALUES (242, 'Inkul', 500); END; / CREATE OR REPLACE PACKAGE plch_arrays IS TYPE employees_t IS TABLE OF plch_employees%ROWTYPE INDEX BY PLS_INTEGER; TYPE emps_by_name_t IS TABLE OF plch_employees%ROWTYPE INDEX BY plch_employees.last_name%TYPE; g_employees employees_t; END; / CREATE OR REPLACE PACKAGE BODY plch_arrays IS BEGIN SELECT *
For the last twenty years, I have managed to transform an obsession with PL/SQL into a paying job. How cool is that?