Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Posts
    51

    Question Unanswered: updating date time automatically

    In each one of our tables we have created a last_change_date column (type datetime). We would like this column to be updated automatically whenever a row is touched. For insert it is easy we can bind the column to a default which can use getdate() function.. But if the row is updated is there any way to update the column without having to specify above column in the column list for update?

    Any help you can provide is appreciated

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    I think you'll have to use an update trigger

  3. #3
    Join Date
    Jan 2004
    Posts
    51

    Question updating date time automatically

    Thanks for replying . But triggers is not really good option.. I would rather go by specifying column in the update statement itself..

    Is there any other method that Sybase provides?

  4. #4
    Join Date
    Sep 2003
    Location
    Switzerland
    Posts
    443
    Another option if you dont mind explicitly mentioning the column in every insert/update statement is getdate() with also a default constraint of getdate() maybe.

    But it has loopholes and not foolproof. If someone goes and manually updates a column using ISQL for eg., you have no choice of tracking it. Thats the reason for pdreyer's answer which covers all audit points.
    Last edited by trvishi; 03-24-08 at 08:45.

Posting Permissions

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