Postgresql – Passing argument in trigger dynamically

postgresqlpostgresql-9.1trigger

CREATE TRIGGER audit_proc_tr
  AFTER INSERT OR UPDATE OR DELETE
  ON "log".hi
  FOR EACH ROW
  EXECUTE PROCEDURE "log".audit_proc(argument);

CREATE OR REPLACE FUNCTION fn_configpurchaseorder(configpurchaseorder, xmode text, xuserno integer)
  RETURNS text AS

 END;

I want to pass xmode is a argument of trigger

Best Answer

If you want to pass data to a trigger that is not provided by one of the predefined variables you could put that data in a temp table before you perform the INSERT/UPDATE/DELETE that will fire the trigger. Then you can retrieve the data from the table inside the trigger function. Temp tables are local to sessions so this is safe to do when multiple clients connect to the same database.