pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: Joachim Trinkwitz <jtr@uni-bonn.de>
Cc: pgsql-sql@postgresql.org
Subject: Re: INSERT only under certain conditions (SELECT)
Date: Tue, 9 Jul 2002 07:18:36 -0500
Message-ID: <20020709121836.GA30146@wolff.to> (raw)
In-Reply-To: <87y9cm1aor.fsf@waffel.germanistik.uni-bonn.de>
References: <874rfb6mqe.fsf@wabe.germanistik.uni-bonn.de>
	<20020708124013.GA30022@wolff.to>
	<87y9cm1aor.fsf@waffel.germanistik.uni-bonn.de>

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.





view thread (5+ messages)

Message-ID: <20020709121836.GA30146@wolff.to>
Permalink:  ../20020709121836.GA30146@wolff.to/
Also on:    postgresql.org/message-id/20020709121836.GA30146@wolff.to

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: bruno@wolff.to, jtr@uni-bonn.de
  Subject: Re: INSERT only under certain conditions (SELECT)
  In-Reply-To: <20020709121836.GA30146@wolff.to>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox