MySQL Forums
Forum List  »  Triggers

Audit Log Trigger - Retrieve Fields Values
Posted by: Athanasios Alekizoglou
Date: December 19, 2011 02:29AM

I am trying to write a generic audit log mechanism implemented with triggers. The trigger would have to be implemented in both AfterInsert and AfterUpdate. Will do a select in an auditfields table and see which fields of a specific table would have to log.

Though I have the following problem. When trying to retrieve the fields' values both NEW and OLD in update or only NEW in insert, I cannot do that. The code I am trying to use is the following, although I know the @ operator will not exactly the work.

DECLARE localFieldName VARCHAR(50) DEFALT NULL;

SET localFieldName = 'strName';
SET strOLD = CONCAT('OLD.', localFieldName);
SET strNEW = CONCAT('NEW.', localFieldName);

IF @strOLD <> @strNEW then
...Insert into table
END IF;



Does anyone think of an alternative way,

Regards
Athanasios Alekizoglou
QUALISYS

Options: ReplyQuote


Subject
Views
Written By
Posted
Audit Log Trigger - Retrieve Fields Values
3838
December 19, 2011 02:29AM


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.