I need to create Trigger for delete action which backsup all fields old value in audit table

Posted by Parth on Stack Overflow See other posts from Stack Overflow or by Parth
Published on 2010-03-31T12:58:37Z Indexed on 2010/03/31 13:53 UTC
Read the original article Hit count: 308

Filed under:
|
|

I need to create Trigger for delete action which backsup all fields old value in audit table.

I have a table structure for audit table as

id, menuid, field, oldvalue, changedone

now whenever any of the row is deleted from its mother table(menu) having 21 fields in count, every fields old value should get insert in the audit table with new audit id..

like If I delete a row having fields as:

menuid, name, age, address, sex, town

now in audit table 6 rows should get inserted seperately for every field given above as:

AUdit Table:

id=2(audittable id) 
             menuid = menuid
             field = name
             oldvalue = joy
             changedone = (whatever the deleted time was)

             id=3(audittable id) 
             menuid = menuid
             field = age
             oldvalue = 23
             changedone = (whatever the deleted time was)

an so on..

© Stack Overflow or respective owner

Related posts about mysql

Related posts about triggers