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

    Unanswered: dbtrigger-Urgent

    i have a table that takes data from another table that data loaded to it every day.
    the table contains the currency rate.
    i need to build a dbtrigger that returns the rates for all currencies
    and in case the rate of one currency was changed i need this last modification to be shown in my table.

    i don't know how can i create a dbtrigger,and what shall i write in it.
    but the case is
    post update+post insert
    if :new.curr_rate != ld.curr_rate
    insert a new record in the table
    end;

    if any one can tell me what exactly shall i do,and if any need more details
    to make more clear no problem.

    Thanks

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Code:
    create trigger trig1
    after insert or update of curr_rate on table1
    for each row
    begin
      if inserting or (:new.curr_rate != :old.curr_rate) then
        insert into table2 ( col1, col2, ... ) values ( ... );
      end if;
    end;
    Note that I assume 2 tables are involved. However, it isn't clear from your question whether the insert in the trigger is into the same table that the trigger is defined on. If that were the case, you would have to write something more complex, to avoid the mutating table issue and infinite recursion.

Posting Permissions

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