pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Graham Vickrage <graham@digitalplanit.com>
To: pgsql-sql@postgresql.org
Subject: Trigger cant find function
Date: Tue, 14 Nov 2000 13:36:15 -0000
Message-ID: <NDBBJABDILOPAOOMFJHOIEJMCFAA.graham@digitalplanit.com> (raw)

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




view thread (2+ messages)  latest in thread

Message-ID: <NDBBJABDILOPAOOMFJHOIEJMCFAA.graham@digitalplanit.com>
Permalink:  ../NDBBJABDILOPAOOMFJHOIEJMCFAA.graham@digitalplanit.com/
Also on:    postgresql.org/message-id/NDBBJABDILOPAOOMFJHOIEJMCFAA.graham@digitalplanit.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: graham@digitalplanit.com
  Subject: Re: Trigger cant find function
  In-Reply-To: <NDBBJABDILOPAOOMFJHOIEJMCFAA.graham@digitalplanit.com>
  References: <NDBBJABDILOPAOOMFJHOIEJMCFAA.graham@digitalplanit.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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