Re: INSERT only under certain conditions (SELECT) - Mailing list pgsql-sql

From Joachim Trinkwitz
Subject Re: INSERT only under certain conditions (SELECT)
Date
Msg-id 87y9cm1aor.fsf@waffel.germanistik.uni-bonn.de
Whole thread Raw
In response to Re: INSERT only under certain conditions (SELECT)  (Bruno Wolff III <bruno@wolff.to>)
Responses Re: INSERT only under certain conditions (SELECT)  (Bruno Wolff III <bruno@wolff.to>)
List pgsql-sql
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| 2002ws7.0| 4326| 2002ws6.1| 4200| 2002ws7.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




pgsql-sql by date:

Previous
From: Jean-Luc Lachance
Date:
Subject: Re: Bad SUM result
Next
From: Roberto Mello
Date:
Subject: Re: manipulating the database in plsql