Domanda

I use the following piece of code for query profiling. However it doesn't create any row in table, plsql_profiler_data. I read that I need to have create or alter privilege in order to generate data. My code is a simple query. Why doesn't it generate profiling data?

declare
x integer;
begin

x := dbms_profiler.start_profiler('1','1');

for rec in (Select la_Name from vv where id BETWEEN 0 AND 999999) loop
    dbms_output.put_line(rec.la_name);
end loop;

x := dbms_profiler.stop_profiler;
x := dbms_profiler.flush_data;
end ;
È stato utile?

Soluzione

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 )

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top