Re: how do i avoid multiple sessions from inserting the - Mailing list pgsql-general

From Kolus Maximiliano
Subject Re: how do i avoid multiple sessions from inserting the
Date
Msg-id A56C8EE648A74A4F9653B071E9F71420B6BE84@bcrweb.bcr.com.ar
Whole thread Raw
Responses Re: how do i avoid multiple sessions from inserting the  (Dennis Gearon <gearond@cvc.net>)
Re: how do i avoid multiple sessions from inserting the  (Dmitry Tkach <dmitry@openratings.com>)
Re: how do i avoid multiple sessions from inserting the  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general

> Why not something like that ?
[...]
> 2) IF NULL -> INSERT INTO users values (....'blah' )  WHERE NOT EXISTS ....
>                -> SELECT id FROM users WHERE email = 'blah'

I tried, but it's giving me an error, as if INSERT wouldn't like the WHERE:

INSERT INTO users (email) VALUES ('john@doe.com')
        WHERE NOT EXISTS
                (SELECT id FROM users WHERE email='john@doe.com');

ERROR:  parser: parse error at or near "WHERE"

(Btw, i didnt know that INSERT would accept a WHERE clause)
 

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: A few questions to real pgsql gurus
Next
From: Dmitry Tkach
Date:
Subject: 7.4?