I have a simple trigger function in PostgreSQL 9.4:
BEGIN
IF (TG_OP = 'UPDATE') THEN
UPDATE relation
SET child_name = new.name
WHERE table_reference_1 = new.id;
END IF;
RETURN NULL;
END;
Is it possible to replace table_reference_1(column name) with a variable? I want to do something like:
BEGIN
IF (TG_OP = 'UPDATE') THEN
UPDATE relation
SET child_name = new.name
WHERE TG_TABLE_NAME = new.id;
END IF;
RETURN NULL;
END;
WHERE TG_TABLE_NAME = new.idmeans:
" new.idequal to the value of the column whose name is equal to the name of the parent table."
source
share