Re: Conditional INSERT: if not exists

From: Franck Routier <franck(dot)routier(at)axege(dot)com>
To: Don Morrison <donmorrison(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Conditional INSERT: if not exists
Date: 2006-08-23 18:57:55
Message-ID: 44ECA533.9000602@axege.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi,

why not simply put a where condition in you insert :

insert into table values (a,b)
where not exists (select a,b from table)

Don Morrison a écrit :
> I want to insert a row unless it exists already. Do I have to write a
> stored procedure to do this?
>
> Thanks,
> Don
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org
>

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Andrej Ricnik-Bay 2006-08-23 19:19:59 Re: protecting a database
Previous Message Keith Worthington 2006-08-23 18:39:01 protecting a database