Re: How can I get one OLD.* field in a dynamic query inside a trigger function ?

From: Bruno Baguette <bruno(dot)baguette(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How can I get one OLD.* field in a dynamic query inside a trigger function ?
Date: 2009-10-26 02:40:45
Message-ID: 4AE50C2D.4030205@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Le 24/10/09 22:57, Pavel Stehule a écrit :
> 2009/10/24 Bruno Baguette <bruno(dot)baguette(at)gmail(dot)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(dot)baguette(at)gmail(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2009-10-26 04:37:24 Re: Can the string literal syntax for function definitions please be dropped ?
Previous Message ginanjar 2009-10-26 01:45:38 indexing