Coat Coat - 1 year ago 69
SQL Question

Alias for a table of type?

I have the following definition for a table type

create table number_table as table of number;

And I'd like to use it like in the following example.

l_myTable number_table := number_table(1, 2, 3);
for i in (select * from l_myTable) loop
dbms_output.put_line(i.???); -- how do I reference the numbers here?
end loop;

Forgive my code being somewhat pointless, how would I reference that
though to get the number out of the iterator?


Just slightly change your query to

select rownum, column_value from l_myTable

and then use dbms_output.put_line(i.rownum); as an index and dbms_output.put_line(i.column_value ); as a value