From: | "Chandra Sekhar Surapaneni" <chandu(at)positivenetworks(dot)net> |
---|---|
To: | "Rahul Patil" <rg_patil(at)rediffmail(dot)com>, <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: can not create trigger with parameter |
Date: | 2005-12-21 16:02:54 |
Message-ID: | 0F7F9A82BB0DBB4396A9F8386D0E0612809289@pos-exch1.positivenetworks.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)postgresql(dot)org
[mailto:pgsql-novice-owner(at)postgresql(dot)org] On Behalf Of Rahul Patil
Sent: Thursday, December 15, 2005 6:57 AM
To: pgsql-novice(at)postgresql(dot)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
<http://adworks.rediff.com/cgi-bin/AdWorks/sigclick.cgi/www.rediff.com/s
ignature-home.htm/1507191490(at)Middle5?PARTNER=3>
From | Date | Subject | |
---|---|---|---|
Next Message | Randy Long | 2005-12-21 16:24:47 | GIS and postgresql |
Previous Message | Johannes Brgmann | 2005-12-21 15:54:43 | plpgsql function returning SETOF |