MySQL Forums
Forum List  »  Triggers

Re: INSERT INTO on AFTER UPDATE trigger
Posted by: JK Heydt
Date: June 26, 2020 06:28AM

Sorry, I want to insert a record into the row_change table for each field that changed in the trigger field:

CREATE DEFINER = CURRENT_USER TRIGGER `hto_demo`.`field_AFTER_UPDATE` AFTER UPDATE ON `field` FOR EACH ROW
BEGIN

IF OLD.FieldID<> new.FieldID
then
INSERT INTO row_change
(RowID, TableCd, FieldID, ChangeDateTime, RecordCreatedBit , DataBefore,DataAfter,UserID)
select
new.RowID
,'FLD'
,'110'
,Getdate()
,0
,old.FieldID
,new.FieldID
,system_user()
from field
end if
END

Repeat IF OLD.Field2<>NEW.Field2 each field.

Options: ReplyQuote


Subject
Views
Written By
Posted
539
June 26, 2020 06:21AM
Re: INSERT INTO on AFTER UPDATE trigger
187
June 26, 2020 06:28AM


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.