Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id D978C9FBCD4 for ; Thu, 29 Mar 2007 18:23:16 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 28225-01 for ; Thu, 29 Mar 2007 18:23:04 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.170]) by postgresql.org (Postfix) with ESMTP id D59599FBCCF for ; Thu, 29 Mar 2007 18:23:06 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id k3so585226ugf for ; Thu, 29 Mar 2007 14:23:06 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=nuakOe7Pkj/DOiuKVkOoHJd0zbD+N07znC4UABCQs6YS3bs1X80v0b2OIX5WWl9T5SvsT+uAffbxaMz8isimucJwwDAf9vpGlR74U5pImL71E76Q5dPEqONfA8Ya9TRJ81AjL4snUrMwRoVVYLc0Jg0R6P2f/adLmXHL2mqcxu0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=NufuSlYuT1CM2B5RUAWYRXeQlGe9h34w5M+ls08WJHBLW++uvom9oAj+KvRYZQo1UZjkIS0xiIjdoC/lesEi9xffwhiSLUAD/7BHoIpxJgadQ65bc+6IoqS2rof0UjUC++yRMcR+gkDnhNBMglEDfdmcxtZdIE9vXJYRcvNLsjM= Received: by 10.114.185.8 with SMTP id i8mr468960waf.1175203382462; Thu, 29 Mar 2007 14:23:02 -0700 (PDT) Received: by 10.114.47.8 with HTTP; Thu, 29 Mar 2007 14:23:02 -0700 (PDT) Message-ID: <4f4c2a010703291423y1fe42ff6rc425a78221f918a3@mail.gmail.com> Date: Thu, 29 Mar 2007 17:23:02 -0400 From: "Jon Horsman" To: "chester c young" Subject: Re: Foreign Unique Constraint Cc: "sql pgsql" In-Reply-To: <415536.67726.qm@web54310.mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4f4c2a010703270621h5137a4e5rb515a9be9034a543@mail.gmail.com> <415536.67726.qm@web54310.mail.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/355 X-Sequence-Number: 27993 > 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 RAISE EXCEPTION ''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.