Re: INSERT only under certain conditions (SELECT)

From: Joachim Trinkwitz <jtr(at)uni-bonn(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: INSERT only under certain conditions (SELECT)
Date: 2002-07-08 15:49:56
Message-ID: 87y9cm1aor.fsf@waffel.germanistik.uni-bonn.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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| 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Roberto Mello 2002-07-08 15:51:50 Re: manipulating the database in plsql
Previous Message Jean-Luc Lachance 2002-07-08 15:22:31 Re: Bad SUM result