Oracle Fine-Grained Auditing (Oracle FGA)

Today my first time using Oracle Fine-Grained Auditing. Why do I need to use Oracle Fine-Grained Auditing?
This is because there is a table that is accessed by many procedures, triggers and packages. So that in case of deletion, I can not track from which the “DELETE” order came from.

I’ve tried using a trigger on a table to track it down. But this action, I think is still not enough. So I tried to use Oracle FGA.

Here’s an example that I use Oracle FGA :

— truncate the audit trail log
CONN sys/password AS SYSDBA
TRUNCATE TABLE fga_log$;

— add the policy TST_AUDIT to the MIS schema all column of the TRD_STATEMENTS table
BEGIN
DBMS_FGA.add_policy (object_schema => ‘MIS’,
object_name => ‘TRD_STATEMENTS’,
policy_name => ‘TST_AUDIT’,
audit_condition => NULL,
audit_column => NULL,
statement_types => ‘DELETE’);
END;

— check the audit trail result
SELECT * FROM dba_fga_audit_trail;

Advertisements

Cancel Oracle Trigger to Execute The Commands

Hi, I want to cancel the trigger of a table that does not work if the logic condition is not met. So as if I want the trigger to rollback (for example = cancel delete in before-delete trigger). At first, the trigger like this :

CREATE OR REPLACE TRIGGER MIS.TRIG01_TABLE_A
BEFORE DELETE
ON PANDAZEN.TABLE_A
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
INSERT INTO PANDAZEN.TABLE_B
SELECT * FROM PANDAZEN.TABLE_A;
END;

The trick to achieve what I want, ie – cancel delete command in the before-delete trigger is to use the command

raise_application_error

So, now triggernya be like this :

CREATE OR REPLACE TRIGGER MIS.TRIG01_TABLE_A
BEFORE DELETE
ON PANDAZEN.TABLE_A
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
IF (:OLD.TABLE_A_VALUE = ‘OLD’) THEN
RAISE_APPLICATION_ERROR (-20000, ‘CANCEL DELETE’);
END IF;

INSERT INTO PANDAZEN.TABLE_B
SELECT * FROM PANDAZEN.TABLE_A;
END;