Thread: trigger with arguments

trigger with arguments

From
Vincent CARON
Date:
Hello everybody,
I have little problems with a function/trigger in Pl/pgSQL.
I want to call this function with 2 arguments:
- the name of a table
- the name of a column
So it looks like :
CREATE  FUNCTION attribute_max(table name,column name)
The creation is successfull, but, when I look after what's the function
looks like, it's something like this:
FUNCTION attribute_max(name,name)

I'm unable to call this function, by a trigger for exemple :
CREATE TRIGGER "trigger" BEFORE INSERT
   ON status FOR EACH ROW
   EXECUTE PROCEDURE public.attribute_max(table1, column1);
I have this error: function public.attribute_max() does not exist.
I have tried to put table1 and column1 into single and double quotes,
and protected by \ also.

Can anyone help me, where am I wrong?
Regards,
Vincent

--
Mes coordonnées - My details : http://covoiturage.fr/contact
Clé - GPG - Key: http://covoiturage.fr/caron.asc

Re: trigger with arguments

From
Keith Worthington
Date:
Vincent CARON wrote:
> Hello everybody,
> I have little problems with a function/trigger in Pl/pgSQL.
> I want to call this function with 2 arguments:
> - the name of a table
> - the name of a column
> So it looks like :
> CREATE  FUNCTION attribute_max(table name,column name)
> The creation is successfull, but, when I look after what's the function
> looks like, it's something like this:
> FUNCTION attribute_max(name,name)
>
> I'm unable to call this function, by a trigger for exemple :
> CREATE TRIGGER "trigger" BEFORE INSERT
>    ON status FOR EACH ROW
>    EXECUTE PROCEDURE public.attribute_max(table1, column1);
> I have this error: function public.attribute_max() does not exist.
> I have tried to put table1 and column1 into single and double quotes,
> and protected by \ also.
>
> Can anyone help me, where am I wrong?
> Regards,
> Vincent
>

Vincent,

"The trigger function must be declared as a function taking
no arguments and returning type trigger."
http://www.postgresql.org/docs/8.0/interactive/triggers.html

--
Kind Regards,
Keith