Re: INSERT only under certain conditions (SELECT)

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: INSERT only under certain conditions (SELECT)
Дата
Msg-id 20020708124013.GA30022@wolff.to
обсуждение исходный текст
Ответ на INSERT only under certain conditions (SELECT)  (Joachim Trinkwitz <jtr@uni-bonn.de>)
Ответы Re: INSERT only under certain conditions (SELECT)
Список pgsql-sql
On Mon, Jul 08, 2002 at 03:18:33 +0200, Joachim Trinkwitz <jtr@uni-bonn.de> wrote:
> Hi,
> 
> I want to insert a row only under condition that there isn't already
> another row with similar values -- something like a INSERT INTO
> ... WHERE NOT EXISTS (SELECT ...)?

You can do something like the following:
insert into tab (col1, col2, col3) select 'val1', 'val2', 'val3' where
not exists (select * from tab where col1 = 'val1' and col2 = 'val2' and
col3 = 'val3');




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

Предыдущее
От: "Rajesh Kumar Mallah."
Дата:
Сообщение: Re: INSERT only under certain conditions (SELECT)
Следующее
От: Carmen Wai
Дата:
Сообщение: Problem on PostgreSQL (error code, store procedures)