Thanks I will try it today and get back here in case of any problems. I
could see "CREATE OR REPLACE" in every trigger example. I am wondering why
we need REPLACE? What is it purpose?
On Thu, Aug 27, 2009 at 1:23 AM, Shane Ambler <pgsql(at)sheeky(dot)biz> wrote:
> Jignesh Shah wrote:
>> Michael, I have one question. I have written a perl code for detecting
>> trigger type(insert, update or delete) and based on that performing the
>> operation. Now I want to make this code as a trigger. Coud you tell me I
>> have to copy paste all written lines while creating function for it or I
>> create file somewhere and give it as a input? Please let me know if below
>> are correct way to do it?
> Copy and paste works - if it is extra long then when using psql you may
> want to use \i /path/to/my/triggerfile
> The \i command can be used to process any valid sql file for input.
> CREATE FUNCTION my_perlfunc (integer, integer) RETURNS VOID
> CREATE FUNCTION my_perlfunc () RETURNS trigger
> Taking no arguments and returning type trigger would be what you are
> looking for. Check chapter 40.6 for how to access column values.
> You will also want to make sure you return "SKIP" or "MODIFY" when
> AS *** Large number of lines Perl code ***
>> LANGUAGE plperl;
>> CREATE TRIGGER my_trigger AFTER INSERT OR UPDATE OR DELETE ON my_table
>> FOR EACH ROW EXECUTE PROCEDURE my_perlfunc(integer, integer);
>> Moreover, I have tried to create trigger like below to execute perl_max
>> function but it gives error. Am I missing something?
>> mydb=# SELECT perl_max(13,9);
>> mydb=# CREATE TRIGGER my_trigger AFTER INSERT OR UPDATE OR DELETE ON
>> mydb-# FOR EACH ROW EXECUTE PROCEDURE perl_max(integer, integer);
>> ERROR: function perl_max() does not exist
>> Thanks for being there.
> Shane Ambler
> pgSQL (at) Sheeky (dot) Biz
In response to
pgsql-novice by date
|Next:||From: Ibrahim Shaame||Date: 2009-08-27 06:58:58|
|Subject: Re: how to install postgresql on windows without admin privileges|
|Previous:||From: Jignesh Shah||Date: 2009-08-27 05:18:13|
|Subject: Re: Perl trigger not working|