Re: Dynamically Referencing OLD/NEW values?
I was having the same issue - I'd like to be able to have the trigger insert into another table the values from the NEW row that was inserted into the table I'm triggering on.
It only works if I hard-code in the column names, so I can't use variables declared like this inside an insert statement:
SET @new_column = CONCAT("NEW.",@column);
which is because of the restriction on dynamic SQL inside the trigger.
Are there any other ways to accomplish this sort of thing inside a trigger?
Perhaps if the trigger is after the insert, get the LAST_INSERT_ID and then:
SELECT @column_name INTO @data FROM your_table WHERE id=@last_insert_id;
and then you could insert @data into your other table?
thanks
Subject
Views
Written By
Posted
8641
January 29, 2013 03:17PM
3233
January 30, 2013 02:40AM
2713
January 31, 2013 12:25PM
Re: Dynamically Referencing OLD/NEW values?
3813
February 06, 2013 01:45PM
2562
February 09, 2013 01:06PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.