PL/SQL 过程如何判断它是否是从并发程序运行的?

Pau*_*ore 2 oracle plsql oracle-apps

我想编写一个过程,该过程在从并发程序运行时将输出记录到 Oracle 并发管理器日志,但在“独立”运行时写入 dbms_output。

PL/SQL 有没有办法检查我的代码是否正在从并发请求运行?我能找到的最好的方法是

select * from fnd_concurrent_requests
where oracle_session_id = userenv('SESSIONID');
Run Code Online (Sandbox Code Playgroud)

但这是相当慢的。是否有可以查询的函数或表可以更有效地为我提供信息?

小智 5

您最好像我们在闪电战报告代码中那样使用 fnd_global.conc_request_id :

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;
Run Code Online (Sandbox Code Playgroud)