Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1j9Ti9-0001uG-Gm for pgsql-general@arkaria.postgresql.org; Wed, 04 Mar 2020 13:05:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j9Ti8-0002jW-9h for pgsql-general@arkaria.postgresql.org; Wed, 04 Mar 2020 13:05:16 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j9Ti7-0002j3-S7 for pgsql-general@lists.postgresql.org; Wed, 04 Mar 2020 13:05:15 +0000 Received: from mailbackend.panix.com ([166.84.1.89]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j9Ti0-0004gc-Ve for pgsql-general@lists.postgresql.org; Wed, 04 Mar 2020 13:05:14 +0000 Received: from panix5.panix.com (panix5.panix.com [166.84.1.5]) by mailbackend.panix.com (Postfix) with ESMTP id 48XYyB6jQ1z1NCZ for ; Wed, 4 Mar 2020 08:05:06 -0500 (EST) Received: by panix5.panix.com (Postfix, from userid 17622) id 48XYyB5BYtzfYm; Wed, 4 Mar 2020 08:05:06 -0500 (EST) Date: Wed, 4 Mar 2020 08:05:06 -0500 From: stan To: pgsql-general@lists.postgresql.org Subject: Calling a function from a rule? Message-ID: <20200304130506.GA10957@panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Editor: gVim List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I am missing something about how to properly create a rule. Thanks to the helpful folks on this list, I am looking a creating some update able views. So, looks like I need to create a rule and a function for this. Here is what I am trying as a test. DROP TRIGGER v_trig_test ON test; CREATE OR REPLACE FUNCTION v_trig_test() RETURNS trigger AS $$ use 5.010; use strict; use warnings; use Data::Dumper qw(Dumper); my $new = Dumper $_TD->{new}; my $old = Dumper $_TD->{old}; elog(NOTICE, "old = $old" ); elog(NOTICE, "new = $new" ); return; $$ LANGUAGE plperlu; CREATE RULE "_RETURN" AS ON UPDATE TO purchase_view DO INSTEAD SELECT * FROM v_trig_test; But the select line in the create rule seems to be a syntax error. Here is my thinking. I have done functions called from triggers, and I am modeling this after that experience, so I think I need the rule to call the function, correct? -- "They that would give up essential liberty for temporary safety deserve neither liberty nor safety." -- Benjamin Franklin