softbless
asked on
Trigger to prevent update in Mysql
Dear All,
Please help me providing trigger in mysql that prevent update of some particular record in a table.
For example :
Name Hobby
------------- -----------
Willy Swimming
Willy Singing
Susan Reading
Marie Reading
Susan Swimming
Michael Soccer
As you can see Susan has 2 hobbies. I want to prevent update if there is a query that update all record with Susan as name.
Please help me providing trigger in mysql that prevent update of some particular record in a table.
For example :
Name Hobby
------------- -----------
Willy Swimming
Willy Singing
Susan Reading
Marie Reading
Susan Swimming
Michael Soccer
As you can see Susan has 2 hobbies. I want to prevent update if there is a query that update all record with Susan as name.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok thanks Sandeepratan
I'll try
I'll try
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
http://dev.mysql.com/doc/refman/5.1/en/create-trigger.html
so, you cannot see inside the trigger if there are several rows being updated.
what you should do is to create a unique index or unique constraint on username + hobbyname, so an update cannot udpate all the rows from 1 username to the same hobby ...