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

From Bruno Wolff III
Subject Re: INSERT only under certain conditions (SELECT)
Date
Msg-id 20020709121836.GA30146@wolff.to
Whole thread Raw
In response to Re: INSERT only under certain conditions (SELECT)  (Joachim Trinkwitz <jtr@uni-bonn.de>)
List pgsql-sql
On Mon, Jul 08, 2002 at 17:49:56 +0200, Joachim Trinkwitz <jtr@uni-bonn.de> wrote:
> 
> 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.

In the database you enforce this using a unique index.
The application needs to be able to handle failures when you try to
insert a duplicate key.

If you can't afford to have a transaction fail part way through, then
anything that writes that table should do a table lock at the start
of the transaction.




pgsql-sql by date:

Previous
From: Jan Wieck
Date:
Subject: Re: Rule WHERE condition problem
Next
From: David Stanaway
Date:
Subject: Re: is there a way to get hh:mm:ss given seconds