Try something like:
begin
dbms_profiler.start_profiler('Test Run 1');
for rec in (Select level as levl from dual connect by level <= 10)
loop
dbms_output.put_line(rec.levl);
end loop;
DBMS_PROFILER.FLUSH_DATA;
dbms_profiler.stop_profiler;
end ;
Once complete, get the runid from the metadata tables:
SELECT *
FROM plsql_profiler_runs
WHERE run_comment = 'Test Run 1'
ORDER BY runid desc;
Assuming the runid = 42, this will show the line detail:
SELECT u.*, d.*
FROM plsql_profiler_units u
JOIN plsql_profiler_data d ON u.runid = d.runid
AND u.unit_number = d.unit_number
WHERE u.runid = 42
ORDER BY u.unit_number, d.line#;
BTW, your posted example doesn't run (one issue is the ; after the "for rec in (...)" part )