Re: Looping through column values in a record without specifying column names?
Date: Wed, 05 Mar 2008 04:51:46 -0800
> In PL/SQL, is there a way to loop through column values in a record
> without specifying column names in advance? e.g. like using an index
> number in an array?
> The code below will output a value for the column specified; but I've
> not found a way to create an inner loop and iterate through the record
> cursor cur is
> select * from my_table;
> for rec in cur
> end loop;
> Tried inserting an inner loop something like the following, and it
> for x in rec
> end loop;
> ... and it failed:
> ERROR at line 7:
> ORA-06550: line 7, column 12:
> PLS-00456: item 'REC' is not a cursor
> ORA-06550: line 7, column 3:
> PL/SQL: Statement ignored
> So I can't use a RECORD in a FOR IN loop. How can I accomplish what I
> want to do some other way?
Cursor loops such as in your example have been obsolete since the introduction of Oracle 9i.
BULK COLLECT into an array indexed by binary integer and you can do this with ease (Morgan's Library at www.psoug.org).
-- Daniel A. Morgan Oracle Ace Director & Instructor University of Washington damorgan_at_x.washington.edu (replace x with u to respond) Puget Sound Oracle Users Group www.psoug.orgReceived on Wed Mar 05 2008 - 06:51:46 CST