I have a requirement to create a History table.Whenever an update or delete is done in few tables through online screen, before update or delete an entry should be there in the history table with the current value in the table with time,user id etc.
But we need to maintain the last 20 entries in the table for a KEY value. Key value in our table is Program Name,status(update,delete),Table name. If we have entry for the 21st time the first entry needs to be deleted. So the history should be maintained only for the last 20 entries.
If we request a update for a row in table 'A' through online screen before updating the table 'A' we need to move the current value from table 'A' to the history table and then update the table 'A' with new values.
So based on the 'status' value from online screen (If its update then the value of status is 'U' and 'D' for delete) we need to insert the current value in the history table.