I am having a problem with a trigger. I created a trigger and a function for when performing an INSERT update a field in the same table. Is returning:
Error: function "loss_func" in FROM has return type trigger that is not supported LINE 1: SELECT * FROM table.loss_func ()
Function
CREATE OR REPLACE FUNCTION loss_func()
RETURNS trigger AS $loss_func$
BEGIN
NEW.dt_creation := to_char(now(), 'YYYY-MM-DD');
RETURN NULL;
END;
$loss_func$ LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION loss_func()
OWNER TO postgres;
Trigger
CREATE TRIGGER tgr_loss
AFTER INSERT ON loss
FOR EACH ROW
EXECUTE PROCEDURE loss_func();
What am I doing wrong?
SELECT * FROM table.loss_func ()why are you doing this ? what are you trying to select with this? this is what causes the error. Remove it and it will try to create your trigger. The execution stopped at the first lineAFTERtriggers can't return NULL. (can't alter values either)