Re: How can I get one OLD.* field in a dynamic query inside a trigger function ? - Mailing list pgsql-general

From Bruno Baguette
Subject Re: How can I get one OLD.* field in a dynamic query inside a trigger function ?
Date
Msg-id 4AE50C2D.4030205@gmail.com
Whole thread Raw
In response to Re: How can I get one OLD.* field in a dynamic query inside a trigger function ?  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-general
Le 24/10/09 22:57, Pavel Stehule a écrit :
> 2009/10/24 Bruno Baguette <bruno.baguette@gmail.com>:
>> Which one would you advise me to learn and use, instead of PL/pgSQL ?
>
> It depends on what you are know (if you known better perl or pthon).
> Usually I using mainly plpgsql and on some functions plperl and C.
> plpgsql is good language as glue of SQL statements, plperl is good for
> IO and CPAN libraries, and C should help with some processor intensive
> functions.

Hello Pavel !

I've read the doc' about plperl and plpython, since I have notion of both.

Because plpython is not a trusted language, I finally took plperl.

In case somebody else does look for the same thing as I was looking for,
here's the new trigger function, rewritten using plperl :

####################################

CREATE OR REPLACE FUNCTION delete_acl_trigger() RETURNS trigger AS
$delete_acl_trigger$
if($_TD->{argc}>0)
{
   for(my $i=0; $i < $_TD->{argc} ; $i++)
   {
     my $acl_id = $_TD->{old}{$_TD->{"args"}[i]};
     my $rv = spi_exec_query("SELECT delete_acl($acl_id);");

     # DEBUG TOOLS
     # my $status = $rv->{status};
     # elog(NOTICE, 'RESULTAT : '.$status);
   }
   return;
}
else
{
   return;
}
$delete_acl_trigger$ LANGUAGE plperl;

####################################

Do I have to mention that it does perfectly what I expected ? :-)

If you have any comments or tips about that function, feel free to do so
  in order to improve it ! :-)

Pavel, many thanks for your tips and explanations !
They were very helpfull ! :-)

Kind regards,

--
Bruno Baguette - bruno.baguette@gmail.com

pgsql-general by date:

Previous
From: ginanjar
Date:
Subject: indexing
Next
From: Pavel Stehule
Date:
Subject: Re: Can the string literal syntax for function definitions please be dropped ?