Trying to create trigger which is supposed to use NEW and OLD and also accept table name as param, but always getting error:
Trying to create trigger which is supposed to use NEW and OLD and also accept table name as param, but always getting error:
You cannot directly call a trigger function from SQL or PL/pgSQL. So this line is wrong
EXECUTE function_update(table_name );
for three reasons:
EXECUTE takes a string containing an SQL function as argument. So PostgreSQL wants to call your function and execute the result as an SQL statement. You mean PERFORM function_update(table_name);, but that is also wrong for the following reasons.
You supply an argument to the function, but you defined it without parameters. This causes the error message.
You are trying to call a trigger function in an SQL statement. That will always fail.
You shouldn't have defined function_update as trigger function, but as normal function that can be called from SQL.