DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: How can I update the area automatically?

  1. #1
    Join Date
    Jul 2002
    Posts
    228

    How can I update the area automatically?

    Hi,
    I've a view LOG_AREA:
    CODE......NAME......ID........AREA
    001.........Tom.........1...........200
    001.........Tom.........2...........300
    124.........John........5...........1000
    124.........Tom.........2...........2000
    124.........Sam.........3...........300
    004.........Sam.........5...........600


    The area of view LOG_AREA change every day.

    for example if this view the day after has this values:

    CODE......NAME......ID........AREA
    001.........Tom.........1..........300
    001.........Tom.........2..........800
    124.........John........5..........300
    124.........Tom.........2..........2000
    124.........Sam.........3..........300
    004.........Sam.........5..........800

    I'd like to get a table "AUDIT_AREA" which does the difference between the current area and the previous area:


    CODE......NAME......ID........AREA_OLD...AREA_NEW....DIFF
    001.........Tom.........1...........200.............300...........100
    001.........Tom.........2...........300.............800...........500
    124.........John........5...........1000...........300.........-700
    124..........Tom........2...........2000...........2000...........0
    124..........Sam........3...........300.............300.............0
    004..........Sam........5..........600............800.............200

    How can I create a statement sql (or procedure) that does this update of area?

    Thanks
    Raf

  2. #2
    Join Date
    Dec 2002
    Location
    Bangalore ( India )
    Posts
    2,434
    Write Trigger before Update on the underlying table of the view.

    BTW, I think you have posted the same query in different post some time back.
    funky...

    "I Dont Want To Follow A Path, I would Rather Go Where There Is No Path And Leave A Trail."

    "Ego is the worst thing many have, try to overcome it & you will be the best, if not good, person on this earth"

Posting Permissions

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


Click Here to Expand Forum to Full Width