我想使用FGA和sys_context('userenv','current_sql')针对特定表记录所有语句我接近我需要但看起来像current_sql总是被截断为256个字符。
我试过看current_sql1到7,但它们总是空的。以下是我用来设置它的代码:
create table emp_audit
( whodidit varchar2(40)
, whenwasit timestamp
, sql_executed varchar2(4000)
, sql_executed1 varchar2(4000)
, sql_executed2 varchar2(4000)
, sql_executed3 varchar2(4000)
, sql_executed4 varchar2(4000)
, sql_executed5 varchar2(4000)
, sql_executed6 varchar2(4000)
, sql_executed7 varchar2(4000)
);
create or replace
package AUDIT_HANDLER
is
PROCEDURE HANDLE_EMP_SAL_ACCESS
( object_schema VARCHAR2
, object_name VARCHAR2
, policy_name VARCHAR2
);
end;
create or replace
package body AUDIT_HANDLER
is
PROCEDURE HANDLE_EMP_SAL_ACCESS
( object_schema VARCHAR2
, object_name VARCHAR2
, policy_name VARCHAR2
) is
PRAGMA AUTONOMOUS_TRANSACTION;
begin
insert into emp_audit
( whodidit, whenwasit, sql_executed, SQL_EXECUTED1, SQL_EXECUTED2, SQL_EXECUTED3, SQL_EXECUTED4, SQL_EXECUTED5, SQL_EXECUTED6, SQL_EXECUTED7)
values
( user, systimestamp, sys_context('userenv','current_sql'),sys_context('userenv','current_sql1'),sys_context('userenv','current_sql2'),sys_context('userenv','current_sql3'),sys_context('userenv','current_sql4'),sys_context('userenv','current_sql5'),sys_context('userenv','current_sql6'),sys_context('userenv','current_sql7'))
;
commit;
end HANDLE_EMP_SAL_ACCESS;
end;
begin
dbms_fga.add_policy
( object_schema=>'EPAT'
, object_name=>'PERSON'
, policy_name=>'PHI_ACCESS_HANDLED'
, handler_schema => 'SBOUCHAR'
, handler_module => 'AUDIT_HANDLER.HANDLE_EMP_SAL_ACCESS'
);
end;
答案 0 :(得分:0)
看起来你必须在sys_context的调用中指定长度:
sys_context('userenv','current_sql',4000)