Function, trigger problem with PL/pgSQL

From: John Duperon <John(dot)Duperon(at)EMBL-Heidelberg(dot)de>
To: pgsql-general(at)hub(dot)org
Subject: Function, trigger problem with PL/pgSQL
Date: 1999-08-06 18:22:29
Message-ID: Pine.OSF.4.04.9908062005560.7419-100000@tau.EMBL-Heidelberg.DE
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

Hello, I'm a novice who has tried and failed to get the C trigger refint.c
to compile. So, I've decided to implement the triggers with PL/pgSQL
instead and to re-write them on my own. But, I can't seem to get my
triggers to acknowledge the existance of the function I've created for
them. Here is the function:

CREATE FUNCTION foreign_key (text, text, text) returns opaque as '
DECLARE
thistable ALIAS for $1;
parenttable ALIAS for $2;
parenttablecolname ALIAS for $3;
BEGIN
if (select count(*) from parenttable where
parenttablecolname=new.parenttablecolname) < 1 then
raise exception ''Foreign Key does not exist in table '',
thistable;
end if;
END;
' LANGUAGE 'plpgsql';

Here is the trigger:

create trigger foreign_key_trigger before insert or update on
tblantibodyrelatedprojects for each row execute procedure
foreign_key('tblantibodyrelatedprojects', 'tblantibody', 'dblantibodyID');

When I try to create this trigger, I get the error
"ERROR: CreateTrigger: function foreign_key () does not exist".

Is there a bug I don't know about or I am I not doing something correctly
(probably the latter)? I've tried passing my parameters without
apostrophes as well as with quotes and have even included the type when
passing them. No dice.

Thanks for your help,

John

P.S. If you respond to this message, could you copy your response to me
personally? I don't always have time to read through all the postings.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Good 1999-08-06 19:52:56 SQL-Ledger new version (fwd)
Previous Message ralli 1999-08-06 17:34:39 List moderator please take me off from this list

Browse pgsql-sql by date

  From Date Subject
Next Message jpjansen 1999-08-07 10:23:39
Previous Message Bruce Momjian 1999-08-06 02:33:32 Re: [SQL] qurey plan and indices