PL/SQL 上的 get_detailed_sqlerrm 语法

Mel*_*oku 4 oracle plsql oracle11g plsqldeveloper

我正在尝试为尝试使用 SOAP Web 服务的函数调试 PL/SQL 上的“HTTP 请求失败”错误。建议使用 get_detailed_sqlerrm 来获取错误消息的详细信息,但是当我尝试运行建议的查询时,它会抛出“无效的 SQL 语句”错误。

我的查询:

UTL_HTTP.get_detailed_sqlerrm 
RETURN VARCHAR2;
Run Code Online (Sandbox Code Playgroud)

我使用的是 PL/SQL Developer IDE,数据库是 Oracle 11g。

Lit*_*oot 8

你可能应该跑

select utl_http.get_detailed_sqlerrm from dual;
Run Code Online (Sandbox Code Playgroud)

请注意 - 它不是通用函数,仅适用于 UTL_HTTP 错误。例如,它不适用于 SQL 错误:

SQL> select deptno, min(sal) from emp;
select deptno, min(sal) from emp
       *
ERROR at line 1:
ORA-00937: not a single-group group function


SQL> select utl_http.get_detailed_sqlerrm from dual;

GET_DETAILED_SQLERRM
--------------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)

...也不适用于 PL/SQL 错误:

SQL> begin
  2    select empno from emp;
  3  end;
  4  /
  select empno from emp;
  *
ERROR at line 2:
ORA-06550: line 2, column 3:
PLS-00428: an INTO clause is expected in this SELECT statement


SQL> select utl_http.get_detailed_sqlerrm from dual;

GET_DETAILED_SQLERRM
--------------------------------------------------------------------------------


SQL>
Run Code Online (Sandbox Code Playgroud)

...但适用于与 UTL_HTTP 相关的错误:

SQL> declare
  2    l_request utl_http.req;
  3  begin
  4    l_request := utl_http.begin_request('http://www.some_company.com');
  5  end;
  6  /
declare
*
ERROR at line 1:
ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1130
ORA-24247: network access denied by access control list (ACL)
ORA-06512: at line 4


SQL> select utl_http.get_detailed_sqlerrm from dual;

GET_DETAILED_SQLERRM
--------------------------------------------------------------------------------
ORA-24247: network access denied by access control list (ACL)

SQL>
Run Code Online (Sandbox Code Playgroud)