Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Convert associative array to nested table

MarwimJan 16 2009 — edited Jan 16 2009
Hello,
I have an associative array where I can store index-value pairs, something like
TYPE t_tab_emp IS TABLE OF emp%ROWTYPE
    INDEX BY PLS_INTEGER;
tab_emp t_tab_emp;
Until now this was a good solution because the index is sparse with a wide range of values, e.g. like empno, and I could simply check whether an element exists or add an element by
IF tab_emp.EXISTS(3456) THEN 
   ...
tab_emp(3498) := ...
The new requirement is to use a SQL-type because it is needed outside PL/SQL.
When I just say
TYPE t_nt_emp IS TABLE OF emp%ROWTYPE;
nt_emp t_nt_emp := t_nt_emp();
I cannot simply use the subscript since it is initially dense and I would have to create (empty) elements until I reach my empno.
Is there a simple way to see in my example whether an element 3456 exists if this number is not the subscript but an element of emp%ROWTYPE?

The elements are filled randomly, have to be updated and finally processed ordered by empno.

Regards
Marcus
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 13 2009
Added on Jan 16 2009
4 comments
1,071 views