IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Automatic delete after n entries in the table for a Keyvalue


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
srajanbose

New User


Joined: 11 Oct 2004
Posts: 69
Location: chennai

PostPosted: Thu Sep 02, 2010 1:11 pm
Reply with quote

Hi,

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.

Please let me know how to achieve this.


Regards,
Rajan BOSE.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Sep 02, 2010 4:15 pm
Reply with quote

how are you determining that you need to INSERT to the History table?
Back to top
View user's profile Send private message
srajanbose

New User


Joined: 11 Oct 2004
Posts: 69
Location: chennai

PostPosted: Thu Sep 02, 2010 4:22 pm
Reply with quote

Hi Dick,

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.


Regards,
Rajan BOSE.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Sep 02, 2010 4:41 pm
Reply with quote

so, you already have code in any module that Updates or Deletes from active table.

I would use Trigger on INSERT/UPDATE to the History table, do a count and delete the earliest.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts DELETE SPUFI DB2 1
No new posts Load new table with Old unload - DB2 DB2 6
No new posts DSNTIAUL driven delete IBM Tools 0
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Multiple table unload using INZUTILB DB2 2
Search our Forums:

Back to Top