Re: Conditional Adding to a Table

From: "Aasmund Midttun Godal" <postgresql(at)envisity(dot)com>
To: glenn(dot)sullivan(at)varianinc(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Conditional Adding to a Table
Date: 2001-10-10 21:52:20
Message-ID: 20011010215220.3041.qmail@ns.krot.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

just add a unique constraint on the things you want to be unique...
On Wed, 10 Oct 2001 14:37:09 -0600, Glenn Sullivan <glenn(dot)sullivan(at)varianinc(dot)com> wrote:
> Greetings,
>
> I need to check a table to see if an item already exist in the table.
> It if does not, then I want to add it. Unfortunately, multiple processes
> (Solaris system) can be running at the same time. Sometimes, one process
> checks to see if an item exist and it does not. At the same time another
> process checks to see if the same item exist and it does not. Then both,
> add the item to the table. This is, of course, not what I want.
>
> I cannot seem to figure out how to do a conditional test to do something
> like this. If I could, then the whole operation could fit in one transaction
> with locking.
>
> Any ideas?
>
> Thanks,
> Glenn
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)

Aasmund Midttun Godal

aasmund(at)godal(dot)com - http://www.godal.com/
+47 40 45 20 46

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Aasmund Midttun Godal 2001-10-10 21:52:35 Re: database field "pointer"
Previous Message Vince Vielhaber 2001-10-10 21:47:24 Re: Contents of greatbridge.com?