Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2003
    Posts
    47

    Unanswered: How to delete data using automatic approach

    I have a table called fm_rel having the following columns
    id,creationtime. Every day we add entries to this table. I need the logic(database trigger) which will identify any record which is older than 7 days and delete the record.

    Can I write a trigger which can identify the age with out doing any manipulations on the record.

    I am not sure it is feasible also , any ideas will be appreciated.


    Shri
    p.srinivasarao

  2. #2
    Join Date
    Nov 2005
    Location
    IL
    Posts
    557
    How about something like

    delete from fm_rel where creationtime < current date -7 days
    --
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows

    DB2 v9.7.0.6 os 6.1.0.0

  3. #3
    Join Date
    Jan 2003
    Posts
    47
    To perform this I should have a process runs everyday. Can we write a intellegent trigger(I don't trigger supports this... some way) which automatically identifies n days older data and delete it automatically. Any ideas?



    Quote Originally Posted by palchuri
    I have a table called fm_rel having the following columns
    id,creationtime. Every day we add entries to this table. I need the logic(database trigger) which will identify any record which is older than 7 days and delete the record.

    Can I write a trigger which can identify the age with out doing any manipulations on the record.

    I am not sure it is feasible also , any ideas will be appreciated.


    Shri
    p.srinivasarao

  4. #4
    Join Date
    Oct 2004
    Location
    DELHI INDIA
    Posts
    338
    Quote Originally Posted by palchuri
    To perform this I should have a process runs everyday. Can we write a intellegent trigger(I don't trigger supports this... some way) which automatically identifies n days older data and delete it automatically. Any ideas?
    Once a trigger is written, its ready for execution always. Make some condition like On INSERT/UPDATE, i mean whenever there will be some action on the source table then the TRIGGER will be FIRED.
    See the Syntax of Triggers for better understanding.

    Thanks,
    Jay

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •