From: | stan <stanb(at)panix(dot)com> |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Calling a function from a rule? |
Date: | 2020-03-04 13:05:06 |
Message-ID: | 20200304130506.GA10957@panix.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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
From | Date | Subject | |
---|---|---|---|
Next Message | stan | 2020-03-04 13:15:48 | Re: Calling a function from a rule? |
Previous Message | hubert depesz lubaczewski | 2020-03-04 11:15:50 | Re: Use of perl modules in plperl ? |