Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mHd2l-0006R7-26 for pgsql-novice@arkaria.postgresql.org; Sun, 22 Aug 2021 02:17:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mHd2k-0004dj-1Y for pgsql-novice@arkaria.postgresql.org; Sun, 22 Aug 2021 02:17:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mHSY9-0006x3-No for pgsql-novice@lists.postgresql.org; Sat, 21 Aug 2021 15:04:45 +0000 Received: from esa04.ucs.mun.ca ([134.153.136.24]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mHSY5-0000oD-7V for pgsql-novice@postgresql.org; Sat, 21 Aug 2021 15:04:42 +0000 IronPort-SDR: vLIH1h/b73JC+ATzkQfOqXNZ67g8JiIXcjMku/K0QTu24f/WiSokUEMzDL3NFl5U8YN/yBK5QQ 9mte0jFeBnIofUPprRPSYJYQ6aJGWue3TyoPwzQ7OjbRd8yD3kwfOxFHtoBqiaO5m8gN2NWRfD CcIq4oo0U+1GvJ9SpeRnOtDVggDbJN4PZe9hps6a543oqUobotiqYdf/oxzxCIT6PrE8B00yi9 AL4gI0rGLhvDZlL6fYWXQWd7pq5/bHheycrvK56NewtjuPasxDiSC6+OMfotRSVkeWRFBAgGtd CpQ= IronPort-HdrOrdr: =?us-ascii?q?A9a23=3AZJT2XqF3y8yzocS9pLqE9ceALOsnbusQ8z?= =?us-ascii?q?AXPiFKKSC9Hfb2qynDpp4mPHzP6Qr5OktPpTnoAsDpfZq2z/JICOcqUIuKYB?= =?us-ascii?q?Proy+hIo1k8OLZqAHdJw=3D=3D?= X-IronPort-AV: E=Sophos;i="5.84,340,1620700200"; d="scan'208";a="64244167" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from cpe00fc8db7a323-cm00fc8db7a320.cpe.net.cable.rogers.com (HELO pyrope.local) ([174.117.202.255]) by smtp04.ucs.mun.ca with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Aug 2021 12:34:38 -0330 User-agent: mu4e 1.5.6; emacs 27.2 From: Roger Mason To: pgsql-novice Subject: triggers and parameters Date: Sat, 21 Aug 2021 12:34:36 -0230 Message-ID: MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello, I have a trigger function: CREATE OR REPLACE FUNCTION foo_insert () RETURNS TRIGGER AS $$ DECLARE BEGIN INSERT INTO foo SELECT * FROM -- how can I pass in the JID given that a trigger function can't take arguments? get_info ( jid ); RETURN new; END; $$ LANGUAGE 'plpgsql'; that calls a function that returns a table: CREATE OR REPLACE FUNCTION get_info (id text) RETURNS TABLE ( jid text, "timestamp" text, tabular_info text ) AS $function$ BEGIN RETURN query WITH a AS ( SELECT public.results.jid AS jid, public.results. "timestamp" AS "timestamp", regexp_split_to_table(info_out, '\n') AS tabular_info FROM public.results WHERE public.results.jid = id ) SELECT * FROM a RETURN; END; $function$ LANGUAGE plpgsql; and a trigger: CREATE TRIGGER btrigger_foo_populate AFTER INSERT ON results FOR EACH statement EXECUTE PROCEDURE foo_insert (); I want to pass a parameter (jid) that will be different for every invocation of 'foo_insert'. I can't see any way to do this in plpgsql. If it can't be done in plpgsql, is there some mechanism to accomplish the task? Thanks, Roger