I need to create a trigger that can insert in an audit table which DML command- insert update delete has been used on a base table plus with machine name.
Please guide me with this.
I need to create a trigger that can insert in an audit table which DML command- insert update delete has been used on a base table plus with machine name.
Please guide me with this.
Let me show you an example:
1.A table my_test where I will make the dml operations
2.An audit table to record the operations
3.A Trigger to capture the values interested.
Now let's make some DML operations over the table
Verify the audit table
You can read all the attributes from sys_context here:
https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions165.htm
The problem with this solution: You will never get the SQL responsible for the operation. CURRENT_SQL in SYS_CONTEXT only works inside a procedure and when it is invoked in a Fine Grain Access (FGA) policy as a handler.
If you need the SQL responsible for the operation, you either construct a FGA policy and a handler, or you use AUDIT which is much better in this specific case.