Function, trigger problem with PL/pgSQL
От | John Duperon |
---|---|
Тема | Function, trigger problem with PL/pgSQL |
Дата | |
Msg-id | Pine.OSF.4.04.9908062005560.7419-100000@tau.EMBL-Heidelberg.DE обсуждение исходный текст |
Список | pgsql-general |
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.
В списке pgsql-general по дате отправления: