Re: Dynamically Referencing OLD/NEW values?
I have the same Problem, but i am a little bit further...
I´ve read the fields dynamically from the infomation_schema.columns Table into an cursor.
Then I will get the field names. Now the last Problem is. To get the valus from the NEW/OLD Table.
for example NEW.my_dynamic_col_name.
Is there anyone with an idea?
There is an error if i want to get the Values with NEW.col_name...
here is my code
CREATE TRIGGER insert_energy_values
AFTER INSERT ON energy_values FOR EACH ROW BEGIN
DECLARE record_not_found INTEGER DEFAULT 0;
DECLARE col_name Text;
DECLARE cur1 CURSOR FOR SELECT column_name FROM information_schema.COLUMNS
WHERE table_name = 'mytable';
DECLARE CONTINUE HANDLER FOR NOT FOUND SET record_not_found = 1;
OPEN cur1;
my_loop: loop
fetch cur1 into col_name;
if record_not_found then
leave my_loop;
end if;
CALL insert_LogEntry ('i','mytable',colname,NEW.col_name,Current_Timestamp,1,USER());
end loop my_loop;
close cur1;
END;
Subject
Views
Written By
Posted
8642
January 29, 2013 03:17PM
Re: Dynamically Referencing OLD/NEW values?
3233
January 30, 2013 02:40AM
2713
January 31, 2013 12:25PM
3815
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.