pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Trigger cant find function
2+ messages / 2 participants
[nested] [flat]

* Trigger cant find function
@ 2000-11-14 13:36  Graham Vickrage <graham@digitalplanit.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Graham Vickrage @ 2000-11-14 13:36 UTC (permalink / raw)
  To: pgsql-sql

I seem to be having difficulty creating a trigger. I have creted the
function and tested it which seems to work fine: -

CREATE FUNCTION get_prod_cost_price (varchar, int8) RETURNS float AS '
DECLARE
	cost FLOAT;
BEGIN
	SELECT cost_price INTO cost FROM product WHERE code = $1;

	IF FOUND THEN
		UPDATE order_detail SET cost_price = cost WHERE order_detail_id=$2;
		RETURN cost;
	END IF;
	RETURN 0;
END;
' LANGUAGE 'plpgsql';

dvd=> select get_prod_cost_price ('DVD368', 10027);
get_prod_cost_price
-------------------
               9.81
(1 row)



Now I try and create the approprate trigger and I get the following:-

CREATE TRIGGER tg_update_order_detail AFTER insert
    ON order_detail FOR EACH ROW
    EXECUTE PROCEDURE get_prod_cost_price('product_id', 'order_detail_id');

ERROR:  CreateTrigger: function get_prod_cost_price() does not exist

It is clear that it does exist so why does the trigger creation code not
find it?

Thanks in advance for any pointers.

Graham




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Trigger cant find function
@ 2000-11-14 16:05  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Graham Vickrage <graham@digitalplanit.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2000-11-14 16:05 UTC (permalink / raw)
  To: Graham Vickrage <graham@digitalplanit.com>; +Cc: pgsql-sql

"Graham Vickrage" <graham@digitalplanit.com> writes:
> ERROR:  CreateTrigger: function get_prod_cost_price() does not exist
> It is clear that it does exist so why does the trigger creation code not
> find it?

Because the code is looking for a function of no arguments, which yours
is not.

The method for dealing with arguments passed to triggers is, um, arcane
--- I think you look in an implicitly declared array named TGARG, or
something like that.  You don't receive them as normal function
arguments, anyway.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2000-11-14 16:05 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-11-14 13:36 Trigger cant find function Graham Vickrage <graham@digitalplanit.com>
2000-11-14 16:05 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox