Search code examples
oracleplsqloracle-apps

How can a PL/SQL procedure tell if it is being run from a concurrent program?


I want to write a procedure that logs output to the Oracle concurrent manager log when run from a concurrent program, but writes to dbms_output when run "standalone".

Is there a way from PL/SQL to check whether my code is being run from a concurrent request? The best way I've been able to find is

select * from fnd_concurrent_requests
where oracle_session_id = userenv('SESSIONID');

but that's pretty slow. Is there a function or table I can query that gives me the information more efficiently?


Solution

  • You can best use fnd_global.conc_request_id like we do in our blitz report code:

    procedure write_log(p_text in varchar2, p_log_level in number default 1) is
    begin
      if fnd_global.conc_request_id>0 then
        fnd_file.put_line(fnd_file.log,p_text);
      else
        fnd_log.string(p_log_level,'XXEN',p_text); --or your dbms_output.put_line() call
      end if;
    end write_log;