Re: Foreign Unique Constraint
От | Jon Horsman |
---|---|
Тема | Re: Foreign Unique Constraint |
Дата | |
Msg-id | 4f4c2a010703291423y1fe42ff6rc425a78221f918a3@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Foreign Unique Constraint (chester c young <chestercyoung@yahoo.com>) |
Список | pgsql-sql |
> use a pre-insert triggers - one for each table. include something like I ended up going this route and it seems to work. Thanks for the help from all. I figured i'd post the solution to the list so it shows up when googled. Also, if my solution can be simplfied i'd appreciate knowing how. This would be the trigger for table1 in my example. CREATE FUNCTION function_name() RETURNS trigger AS ' DECLARE result RECORD; BEGIN SELECT INTO result * FROM table2 WHERE extension=NEW.extension; IF FOUND THEN RAISEEXCEPTION ''The extension % is already in use'', NEW.extension; END IF; RETURN NEW; END; ' LANGUAGE plpgsql; CREATE TRIGGER function_name BEFORE INSERT OR UPDATE ON table1 FOR EACH ROW EXECUTE PROCEDURE function_name(); Again, thanks for the help. Jon.
В списке pgsql-sql по дате отправления: