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!

Can I select element number from table collection expression?

M. NeiferNov 21 2012 — edited Nov 22 2012
Hi, I know I can use COLUMN_VALUE to select column values from table collection expression. Is there any way to select the number of the element as well? (with Oracle 11.2.0.1.0)
CREATE OR REPLACE TYPE plch_numbers_nt IS TABLE OF NUMBER;
/

DECLARE
   l_numbers   plch_numbers_nt
                  := plch_numbers_nt (10,
                                      20,
                                      30,
                                      40,
                                      50);
BEGIN
   -- This would be nice...
   FOR rec IN (SELECT COLUMN_VALUE, VALUE_INDEX FROM TABLE (l_numbers))
   LOOP
      DBMS_OUTPUT.put_line (rec.COLUMN_VALUE, rec.VALUE_INDEX);
   END LOOP;
END;
/
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 20 2012
Added on Nov 21 2012
14 comments
1,007 views