Re: insert only if conditions are met?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: insert only if conditions are met?
Дата
Msg-id 2099.1125501741@sss.pgh.pa.us
обсуждение исходный текст
Ответ на insert only if conditions are met?  (Henry Ortega <juandelacruz@gmail.com>)
Список pgsql-sql
Henry Ortega <juandelacruz@gmail.com> writes:
> Is there a way to insert a record only if a certain
> condition is met?

> Something like:
> insert into employee values('lastname','firstname',8) where
> (condition here.. select sum(ofsomething) from xx where sum(ofsomething)>0 =
> )

> Is this possible at all with just plain SQL?

Instead of INSERT ... VALUES, use INSERT ... SELECT.
        regards, tom lane


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

Предыдущее
От: Joost Kraaijeveld
Дата:
Сообщение: Re: [GENERAL] How do I copy part of table from db1 to db2
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: insert only if conditions are met?