I need to setup 2 SQL triggers in CartoDB that will update my inland and coastal tables each time my obs table is updated. I have never setup a SQL trigger but I have looked at the documentation and it appears as though I need to have a function stored somewhere that the trigger activates.
So far my first trigger looks like this:
CREATE TRIGGER update_inland
AFTER INSERT ON obs
FOR EACH ROW
EXECUTE PROCEDURE update_inland()
But I get an error message that "function update_inland() does not exist". I want my function to be this:
UPDATE inland SET lt_dispatch_level = obs.named_lt_dispatch_level
FROM obs
WHERE obs.created_at = (SELECT MAX(created_at) FROM obs)
AND inland.cartodb_id = 1
How can I create this function and subsequent trigger in CartoDB? I have been reading the documentation for both Postgres triggers and functions but I need some help.