Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 04928476BF8 for ; Mon, 8 Jul 2002 13:44:37 -0400 (EDT) Mailbox-Line: From jtr@uni-bonn.de Mon Jul 8 13:44:37 2002 Received: from waffel.germanistik.uni-bonn.de (waffel.germanistik.uni-bonn.de [131.220.90.150]) by postgresql.org (Postfix) with ESMTP id A3B4D476156 for ; Mon, 8 Jul 2002 11:50:50 -0400 (EDT) Received: by waffel.germanistik.uni-bonn.de (Postfix, from userid 1000) id 26C6413198E; Mon, 8 Jul 2002 17:49:56 +0200 (CEST) To: pgsql-sql@postgresql.org Subject: Re: INSERT only under certain conditions (SELECT) References: <874rfb6mqe.fsf@wabe.germanistik.uni-bonn.de> <20020708124013.GA30022@wolff.to> From: Joachim Trinkwitz Date: 08 Jul 2002 17:49:56 +0200 In-Reply-To: <20020708124013.GA30022@wolff.to> Message-ID: <87y9cm1aor.fsf@waffel.germanistik.uni-bonn.de> Lines: 32 User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Status: No, hits=-5.3 required=5.0 tests=IN_REP_TO,X_NOT_PRESENT version=2.30 X-Spam-Level: X-Archive-Number: 200207/96 X-Sequence-Number: 8475 Maybe I should explain my problem a little bit: simplified, I have two tables, L and T, (which values references to L): L: art|kvvnr|semester ---+-----+-------- 7.0| 4151| 2002ws 7.0| 4326| 2002ws 6.1| 4200| 2002ws 7.0| 4151| 2001ws (combination of kvvnr and semester is unique) T: id |semester|kvvnr ----+--------+----- 123| 2002ws |4151 123| 2001ws |4151 Now I want to allow a user with id 123 only to insert a row in T if he doesn't choose values from L with same 'art' and 'semester' values -- in the examples user 123 has already chosen a kvvnr from semester 2002ws in category 'art', so he shouldn't be allowed to insert the values of the second row in table L. I hope, someone has followed this complicated thing up to here and there is a solution for my problem. Greetings and thanks for your answers by now and further on, joachim