Re: insert only if conditions are met?

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: insert only if conditions are met?
Дата
Msg-id 20050831152534.GA18934@winnie.fuhr.org
обсуждение исходный текст
Ответ на insert only if conditions are met?  (Henry Ortega <juandelacruz@gmail.com>)
Список pgsql-sql
On Wed, Aug 31, 2005 at 11:09:54AM -0400, Henry Ortega wrote:
> 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 )

See the INSERT documentation; it mentions inserting values from a subquery.

INSERT INTO employee
SELECT 'lastname', 'firstname', 8
WHERE <condition>;

-- 
Michael Fuhr


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: insert only if conditions are met?
Следующее
От: Henry Ortega
Дата:
Сообщение: Re: insert only if conditions are met?