views:

15

answers:

1

Hi. I have a table called posts having an INT field posted and a table domains having field posted too, this one is supposed to be the sum of a posteds of posts belonging to a certain domain. Whether the post belongs to a domain is determined by a foreign domain_id in the table posts which links to the id in domains. I'm trying to create a trigger that would update the posted of a domain every time the posted is changed for any of its posts. Here's what I was trying:

CREATE TRIGGER [update_posted]
AFTER UPDATE OF [posted]
ON posts
BEGIN
UPDATE domains SET posted = posted + NEW.posted - OLD.posted WHERE id = NEW.domain_id 
END

which complains about bad syntax near END. What's the problem?

+2  A: 

Add a ; to the end of your update statement.

Blorgbeard
thanks))........
htf