| From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
|---|---|
| To: | Joachim Trinkwitz <jtr(at)uni-bonn(dot)de> |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: INSERT only under certain conditions (SELECT) |
| Date: | 2002-07-09 12:18:36 |
| Message-ID: | 20020709121836.GA30146@wolff.to |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
On Mon, Jul 08, 2002 at 17:49:56 +0200,
Joachim Trinkwitz <jtr(at)uni-bonn(dot)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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jan Wieck | 2002-07-09 13:00:13 | Re: Rule WHERE condition problem |
| Previous Message | David BOURIAUD | 2002-07-09 08:36:17 | SQL problem with aggregate functions. |