Re: can not create trigger with parameter

Поиск
Список
Период
Сортировка
От Chandra Sekhar Surapaneni
Тема Re: can not create trigger with parameter
Дата
Msg-id 0F7F9A82BB0DBB4396A9F8386D0E0612809289@pos-exch1.positivenetworks.net
обсуждение исходный текст
Ответ на can not create trigger with parameter  ("Rahul Patil" <rg_patil@rediffmail.com>)
Список pgsql-novice
A trigger function must be declared with no arguments and return type trigger. If the function expects arguments then you should use TG_ARGV to parse the parameters inside the function. Look up "Trigger Procedures" in PL/pgSQL in the documentation.
 
-Chandra Sekhar Surapaneni


From: pgsql-novice-owner@postgresql.org [mailto:pgsql-novice-owner@postgresql.org] On Behalf Of Rahul Patil
Sent: Thursday, December 15, 2005 6:57 AM
To: pgsql-novice@postgresql.org
Subject: [NOVICE] can not create trigger with parameter

Hi,

I'm having trouble getting a trigger to use a parameter,  as in the
following simplified example:

CREATE FUNCTION fun_version_table(varchar)
RETURNS opaque
AS 'DECLARE
   
        in_table_name ALIAS FOR $1;
        v_counter  integer;

        BEGIN
                SELECT INTO v_counter counter FROM version_table
                WHERE table_name = in_table_name;      
-- do something in here
                RETURN new;
        END;'
LANGUAGE 'plpgsql';

CREATE TRIGGER trig_deg_master
AFTER
INSERT OR UPDATE OR DELETE
ON author
FOR EACH ROW
EXECUTE PROCEDURE fun_version_table('degree_master');

Function gets created successfully.But
when I create trigger I get an error:

ERROR:CreateTrigger: function fun_version_table() does not exist

I've created triggers/functions with no parameters and they work fine.

The Postgresql book has some examples of functions with paramters, but
I cannot find anywhere a trigger which calls a function with parameters,

although the users manual indicates that parameters are allowed in the
syntax for CREATE TRIGGER.
 

Regards,
Rahul


В списке pgsql-novice по дате отправления:

Предыдущее
От: Oleg
Дата:
Сообщение: Re: transfer database from Linux to Windows
Следующее
От: Randy Long
Дата:
Сообщение: GIS and postgresql