From: | Alan Hodgson <ahodgson(at)simkin(dot)ca> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Cc: | Michael Rowan <mike(dot)rowan(at)internode(dot)on(dot)net> |
Subject: | Re: Problem with CREATE TRIGGER |
Date: | 2012-08-28 23:35:38 |
Message-ID: | 1393196.TqNqYySYeP@skynet.simkin.ca |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Wednesday, August 29, 2012 08:52:23 AM Michael Rowan wrote:
> Hi
> In Postgres 9.1 I have a function as a test (of my ability):
>
> CREATE OR REPLACE FUNCTION insert_payment(integer, numeric)
> RETURNS numeric AS
> $BODY$
> UPDATE company
> SET co_payments=co_payments+$2
> WHERE co_id=$1
> RETURNING co_payments;
> $BODY$
> LANGUAGE sql VOLATILE
> COST 100;
> ALTER FUNCTION insert_payment(integer, numeric)
> OWNER TO postgres;
>
> This function exists, according to pgAdminIII
>
> So I attempt to create a trigger:
>
> CREATE TRIGGER increment_payments
> AFTER INSERT ON payment
> FOR EACH ROW
> EXECUTE PROCEDURE insert_payment();
>
> ERROR: function insert_payment() does not exist
>
> What am I doing wrong here?
>
PostgreSQL allows a basic form of function overloading. That is,
insert_payment() is not the same function as insert_payment(integer,numeric).
Both could exist and need to be referred to explicitly.
Also, trigger functions cannot take arguments (since there is no way to supply
them). And they should (probably must?) return type TRIGGER. So this function
couldn't be a trigger function.
From | Date | Subject | |
---|---|---|---|
Next Message | Bartosz Dmytrak | 2012-08-29 11:47:25 | Re: Problem with CREATE TRIGGER |
Previous Message | Michael Rowan | 2012-08-28 23:22:23 | Problem with CREATE TRIGGER |