I’m searching for a long time for some way to iterate through PL/SQL row, but I did not get any appropriate results.
For example, if I have a PL/SQL row that looks like this row(first_name,last_name) and I want to print the first name and the last name using PL/SQL without knowledge about the row i.e. I don’t know how the row looks like so I need some kind of code that looks like this
FOR column IN My_Row --some way to iterate through the row.
LOOP
PRINT column... --do my stuff, in this example
END LOOP;
If you know the name of the table the row is from then you can get the names of the columns from
ALL_TAB_COLUMNS. You can build a dynamic SQL around that. See this Ask Tom article regarding something like this: Referencing %rowtype variables without using column names.Based upon your comment you’ll be going through all your tables so you can use
ALL_TABLESto get all their names. Though remember thatALL_TABLESis all tables your login has access to whileDBA_TABLESis every table in the database andUSER_TABLESis those that your user owns.