Oracle Apex ORA-14551:无法在查询提示内执行DML操作

时间:2016-11-24 11:42:11

标签: oracle plsql oracle-apex

我使用APEX 4.2。

我使用此查询的交互式报告:

    select col1, col2, col3, col4 
    from MyTable
    where function_check_user('ADMIN');

如果具有角色' ADMIN'的用户可以显示查询结果,则函数 function_check_user()将返回1。我正在使用APEX程序 apex_util.public_check_authorization()

create or replace FUNCTION function_check_user
(
  xrole  VARCHAR2
)  
return integer IS
xcheck  BOOLEAN;

begin
    xcheck:= apex_util.public_check_authorization(xrole);
  if xcheck then
     return 1;
  end if;
     return 0;
end;

问题: 我使用查询设置了inetractive报告,并尝试在我的应用程序上运行它。我有这个错误:

Oracle Apex ORA-14551: cannot perform a DML operation inside a query tips.

当我在where子句中使用没有函数的查询时,它可以工作:

select col1, col2, col3, col4 
from MyTable;

使用 apex_util.public_check_authorization()程序是否存在问题?

由于

1 个答案:

答案 0 :(得分:1)

您可以通过在函数中声明pragma autonomous_transaction来解决它。

create or replace FUNCTION function_check_user
(
  xrole  VARCHAR2
)  
return integer IS
pragma autonomous_transaction;
xcheck  BOOLEAN;

begin
    xcheck:= apex_util.public_check_authorization(xrole);
    rollback;
  if xcheck then
     return 1;
  end if;
     return 0;
end;
相关问题