0

Code to move from one table to other upon deletion, is this correct?

 create or replace TRIGGER Trans_history_s
    AFTER DELETE
        ON trans_s
        REFERENCING NEW AS trans_s
        FOR EACH ROW
    BEGIN
        INSERT INTO trans_history_s values (:old.book_no,:old.mem_no,sysdate,sysdate,sysdate);
    END;
Natalie Hedström
  • 2,607
  • 3
  • 25
  • 36
  • 1
    It looks like it might work. You should list the column names in the insert statement (`INSERT INTO trans_history_s (col1, col2, ...)...`) and the `referencing` line does nothing useful and can be removed, – Tony Andrews Jan 27 '16 at 10:28

1 Answers1

1

Yes, this is correct and as @TonyAndrews has already stated, you should always explicitly define the columns you are referring to, to avoid relying on the column order.

Keep in mind that - though possible - you should never rely on the order of columns in a table. When adding columns, Oracle will always put these at the end.

Community
  • 1
  • 1