I have a trigger function that is going to audit transactions made on a table.
CREATE or REPLACE FUNCTION audit()
returns trigger
language plpgsql
as $$
begin
EXECUTE FORMAT ('INSERT INTO %I.audit VALUES (%L,%L,%L)',TG_TABLE_SCHEMA, TG_TABLE_NAME, TG_OP, now());
RETURN NEW;
end;
$$
However I keep getting "ERROR: invalid input syntax for integer: "triggerTable" Where: PL/pgSQL function audit() line 3 at EXECUTE statement" (Where trigger table is the table that has triggered this function)
Is the I assume the syntax of my execute query is wrong, but I can't isolate where. Any feedback would be welcome