Re: INSERT WHERE NOT EXISTS

Поиск
Список
Период
Сортировка
От Reuben D. Budiardja
Тема Re: INSERT WHERE NOT EXISTS
Дата
Msg-id 200306251553.01149.techlist@voyager.phys.utk.edu
обсуждение исходный текст
Ответ на Re: INSERT WHERE NOT EXISTS  (Ian Barwick <barwick@gmx.net>)
Ответы Re: INSERT WHERE NOT EXISTS  (Jonathan Bartlett <johnnyb@eskimo.com>)
Список pgsql-general
On Wednesday 25 June 2003 03:26 pm, Ian Barwick wrote:
<snip>
> > I vaguely remember in Oracle, there is something like this:
> >
> > INSERT INTO mytable
> > SELECT 'value1', 'value2'
> >     FROM dummy_table
> >   WHERE NOT EXISTS
> >         (SELECT NULL FROM mytable
> >                 WHERE mycondition)
> >
> > This query will do INSERT, if there is not an entry already in the TABLE
> > mytable that match the condition mycondition. Otherwise, the INSERT just
> > fails and return 0 (without returning error), so I can check on that and
> > do update instead.
>
> This kind of query should work; just leave out the "FROM dummy_table" bit.
> (in Oracle it would be "FROM dual").

Hi,
this seems to work. Thanks. Don't know why I didn't just try it. And yes, in
Oracle it's SELECT .. FROM dual.

RDB
--
Reuben D. Budiardja
Department of Physics and Astronomy
The University of Tennessee, Knoxville, TN
-------------------------------------------------
/"\  ASCII Ribbon Campaign against HTML
\ /  email and proprietary format
 X   attachments.
/ \
-------------------------------------------------
Have you been used by Microsoft today?
Choose your life. Choose freedom.
Choose LINUX.
-------------------------------------------------


В списке pgsql-general по дате отправления:

Предыдущее
От: dalgoda@ix.netcom.com (Mike Castle)
Дата:
Сообщение: Re: NIST test defects
Следующее
От: Ian Barwick
Дата:
Сообщение: Re: INSERT WHERE NOT EXISTS