• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Auditing Table

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have the following clarification

I have an Employee Table

Employee

Name
Age
Gender
Last_Updated_User
Last_Updated_Time

are the columns in the Employee Table

I also have a generic audit table that I can use with the same format for my application

The Structure of the audit table would be



Column_Name
Old_Value
New_Value
Last_Updated_User
Last_Updated_Time


Expected Behaviour:

Insertion:

1. Whenever a new row has been inserted inside the master table, each column must be inserted as a row in the audit table with the old_value as null and new_value as insertion value


Updation:
1. Whenever a row has been updated inside the master table, each column that is updated only must be inserted as a row in the audit table with the old_value as old value and new_value as updated value

Deletion:

1. Whenever a row has been deleted from the master table, each column that is from the master table be inserted as a row in the audit table with the old_value as last value and new_value as null

How do I achieve this?

Please provide me with a Sample. Am new to Triggers and PL/SQL.

Thanks in Advance








 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, welcome to the ranch You'll find plenty of examples on the net about using triggers. Try to google it first.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic