Results 1 to 2 of 2

Thread: Storing old values after UPDATE

  1. #1
    kfdiw Guest

    Storing old values after UPDATE

    When I update a field f1 I should store its previous value in the field f2. How can I achieve this?

  2. #2
    Gregory Guest

    Storing old values after UPDATE (reply)

    1) you can use triggers
    for example:update trigger (will be used only for update)

    create trigger <trigger_name> on <table_name>
    for update
    as
    if update (field1)
    /* that will make sure that trigger is used only if field1 si being changed */
    update <table_name> set field2 = deleted.field1
    where <where clause to make sure only row that needs to be updated is changed>

    -or-
    2. in update statement (w/o using triggers):
    update <table_name>
    set field2 = field1,
    field1 = <new value>

    -or-
    3. create simple stored procedure, that will take new value for field1 as a parameter


    ------------
    kfdiw at 3/15/99 11:13:25 AM

    When I update a field f1 I should store its previous value in the field f2. How can I achieve this?

Posting Permissions

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