I would like to run the FOR LOOP in Oracle based on a parameter that is dynamically populated. Please see, how the code could look like:
declare
idx number := (select max(field_name) from table_name);
begin
for i in 1..idx loop
dbms_output.put_line (i);
end loop;
end;
So basically if the select max(field_name) from table_name returns for example 10, the loop should be run 10 times (for i in 1..10 loop).