CREATE FUNCTION update_status() RETURNS TRIGGER AS '
BEGIN
SELECT status FROM animals
IF status = "Alive"
THEN
UPDATE animals SET status = "Sold" WHERE status="Alive";
END IF;
RETURN NULL;
END; ' LANGUAGE plpgsql;
CREATE TRIGGER updatetrigger AFTER UPDATE OF id_selling ON animals EXECUTE PROCEDURE update_status();
It says I'm not using the selected attributes, and I should use Perform instead of Select. But then it doesnt recognize the IF after the perform. I'm really new to these syntax, so it might be wrong. I think its clear what I want to do (and i believe it simple for someone with experience). Can you please help me with this problem?