I have a number of tables that use the Postgres \"Partitioning\" feature. I want to define a common BEFORE INSERT OF ROW trigger on each table that will 1) dynamically crea
You can use EXECUTE USING
to pass NEW to it. Your example would be
EXECUTE 'INSERT INTO ' || TG_RELID || '::regclass SELECT $1' USING NEW;
(Note that I use TG_RELID casted to regclass instead of fiddling with TG_TABLE_SCHEMA and TABLE_NAME because it is easier to use, if nonstandard. But then, plpgsql is nonstandard anyway.)