I'm trying to produce a trigger for any cinema database. I want it to update when a rating is added for any movie showing the written text "rating added". The table title is
the main secret is = movie_rating
I'm not really sure how to get it done, I've looked online but nonetheless aren't too sure. I'm wondering if anybody may help.
This is actually the syntax to produce a trigger that will fire whenever a row is placed.
create trigger movie_rating_added on movie_ratings for insert as -- trigger code goes here go
Within the trigger, you can get an online table known as
inserted, that has exactly the same schema as
movie_ratings, but which consists of just the rows that have been placed.
I am not obvious on exactly what you would like the trigger to complete, but for instance you could do this something similar to this:
create trigger movie_rating_added on movie_ratings for insert as update m set last_action = "rating added" from movies m join inserted i on i.movie_id=m.id go
That is assuming the presence of some fields and tables which you may not have access to, but hopefully it offers a superior a helpful example.