I have a problem with my trigger:
CREATE OR REPLACE FUNCTION process_fillDerivedFrom_used() RETURNS TRIGGER AS $fillDerivedFrom_used$
DECLARE
prog varchar(255);
current varchar(255);
BEGIN
SELECT u.iduseentity as prog ,g.idCreatedEntity as current
FROM entity e
JOIN used u ON e.identity=u.iduseentity
JOIN activity a ON a.idactivity=u.idusedactivity
JOIN generatedby g ON g.idcreatoractivity=a.idactivity
INSERT INTO DERIVEDFROM VALUES (prog,current)
END;
$fillDerivedFrom_used$ LANGUAGE plpgsql;
CREATE TRIGGER fillDerivedFrom_used
AFTER INSERT OR UPDATE OR DELETE ON emp
FOR EACH ROW EXECUTE PROCEDURE process_fillDerivedFrom_used();
I use 3 tables, the query is correct so I think the error doesn't come from here. But when I copy past this trigger in my terminal nothing happen, no error message, I can write in terminal but I can't execute any query, like I have forgot something in my trigger so I think it's not completely created I think.
I think I mix 2 languages PL/SQL that I have learn at school and the postgresql.
Thank you for you help
insert into DERIVEDFROM select ...all_your_select...?.. keep in mind - you dont operate NEW or OLD record here - it does not look like trigger function at all