Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2004

    Question Unanswered: function to get previous record value of a particular column???

    can anyone tell me equivalent for lag function in sybase????
    for example in oracle we can use lag function to get previous record value of a particular column.
    similarly in sybase please let me know the function to get previos record value of particular column.

    thanks in advance

  2. #2
    Join Date
    Jun 2003
    You can create a trigger for a table to fire on insert, update and/or delete. Within a trigger, the special tables "inserted" and "deleted" are available. Actually, I believe these are special views to the transaction log.

    For example, an update trigger could mainatin a log table of changes. the statement "update tableA set col1="new value" could fire an update trigger which has:

    select @old_value-d.col1,@new_value=i.col1 from inserted i, deleted d
    insert into LogTable values(@old_value,@new_value)

    Hope this helps.

Posting Permissions

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