Logging trigger
Bart Pietercil
bart.pietercil at gmail.com
Mon Oct 15 09:18:40 CDT 2007
Hi List, Ruslan
I am thinking about the feasibility of this:
inside an after update trigger it would like to do
Loop over all the fields of a given table comparing the new values
with the old values.
This way I can write to a log table the old values and the new values.
Is there a way to "read" what fields will be modified? Or do I have
to loop over all the field names. I know I can get all the fields of
a table inside a cursor with the SHOW COLUMNS OF Table command. But
this feels like a way that would generate way too much overhead. When
only one field is updated I still would need to loop over all the
fields, comparing their old values to the new values.
Can I use the name retrieved with the show columns command combined
with new (or old) like this
1) declare cursor = SHOW FIELDS OF table
2)How do I get to the name column of this cursor ????
3) I set local variable thisField = value of current row of cursor
(column('name'))
4) now I should be able to say IF new.thisField IS NOT EQUAL TO
old.thisField then
INSERT INTO tbl_log(f1,f2,...)VALUES(old.ThisField,new.ThisField,.....)
Is this somehow possible.
It seems to me we are very close to this but not yet possible.:-(
Please advice
TIA
Bart Pietercil
PS: other ways of getting to a workable logging solution are of
course welcome. But the solution would need to be contained within
Valentina
More information about the Valentina
mailing list