Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2004
    Location
    Haaksbergen, Netherlands
    Posts
    69

    Answered: Need help with trigger

    Hi,

    I need help defining a trigger on a (one) table.

    Situation:
    Two fields: A and B
    When field A changes (only when changes), the value before the update must be written in field B

    Can anyone help me?
    Oracle version is 11gr2

    Kind regards,

    Wim Venema

  2. Best Answer
    Posted by Littlefoot

    "Something like this?
    Code:
    create table test (col number, col_old number);
    
    create or replace trigger trg_bu_test
      before update on test
      for each row
    begin
      if :new.col <> :old.col then
         :new.col_old := :old.col;
      end if;
    end;
    /
    "


  3. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Something like this?
    Code:
    create table test (col number, col_old number);
    
    create or replace trigger trg_bu_test
      before update on test
      for each row
    begin
      if :new.col <> :old.col then
         :new.col_old := :old.col;
      end if;
    end;
    /

  4. #3
    Join Date
    Jun 2004
    Location
    Haaksbergen, Netherlands
    Posts
    69
    Almost:
    before update of col on test

    Many thanks,

    Wim Venema

Posting Permissions

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