ORBADA » Documentation in English » Plug-in documentation » Oracle Tune » SQL Profiler view » Integration with external programs

4.A.2.1.4.1. Start

DECLARE
  l_result  PLS_INTEGER;
BEGIN
  l_result := DBMS_PROFILER.start_profiler(SYSDATE, 
    'SESSIONID:'||userenv('SESSIONID')||' TERMINA:'||userenv('TERMINAL')||' USER:'||USER, :runid);
END;

After this, parameter :RUNID must be taken, you will need later.

4.A.2.1.4.2. Stopping

DECLARE
  l_result  PLS_INTEGER;
BEGIN
  l_result := DBMS_PROFILER.stop_profiler;
  dbms_profiler.rollup_run(:runid);
END;

Parameter :RUNID is required, taken after the start code

4.A.2.1.4.3. Pause

DECLARE
  l_result PLS_INTEGER;
BEGIN
  l_result := dbms_profiler.flush_data;
  l_result := dbms_profiler.pause_profiler;
  dbms_profiler.rollup_run(:runid);
END;

Parameter :RUNID is required, taken after the start code.

4.A.2.1.4.4. Resume

DECLARE
  l_result PLS_INTEGER;
BEGIN
  l_result := dbms_profiler.resume_profiler;
END;

4.A.2.1.4.5. Adjusting the results to display sources

Run this code, just after the execution "stop" block of SQL Profiler

DECLARE
  offset NUMBER;
  CURSOR c1_triggers IS
    SELECT unit_owner, unit_name, unit_type, unit_number
      FROM plsql_profiler_units
     WHERE runid = :runid
       AND unit_type = 'TRIGGER';
BEGIN
  FOR c1 IN c1_triggers LOOP
    SELECT NVL(MIN(line) - 1, -1)
      INTO offset
      FROM all_source
     WHERE owner = c1.unit_owner
       AND name  = c1.unit_name
       AND type  = c1.unit_type
       AND (UPPER(text) LIKE '%BEGIN%' OR UPPER(text) LIKE '%DECLARE%');
    IF offset > 0 THEN
      UPDATE plsql_profiler_data
         SET line# = line# + offset
       WHERE runid = :runid
         AND unit_number = c1.unit_number;
    END IF;
  END LOOP;
  COMMIT;
END;

Parameter :RUNID is required, taken after the start code.

ORBADA » Documentation in English » Plug-in documentation » Oracle Tune » SQL Profiler view » Integration with external programs