Howto "insert or update" ?

Поиск
Список
Период
Сортировка
От Andreas
Тема Howto "insert or update" ?
Дата
Msg-id 4CEB38B0.8050901@gmx.net
обсуждение исходный текст
Ответы Re: Howto "insert or update" ?
Список pgsql-sql
Hi,
is there an elegant way to tell PG :

a)   Hey PG, look here are e.g. 3 values  A, B, c  for tableX
b)   please check if there is a row matching  A and B  as key in tableX
c)   if such a row exists, execute an UPDATE on column c else INSERT a 
new row.

Currently I have a trigger function that should store a value in tableX 
whenever a certain column in tableY gets changed.
I do it with:
a)   delete from tableX where key = ( A, B )  ( regardless if there is one )
b)   insert into tableX

This seems not very efficient though it works.
Is there a better way?


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

Предыдущее
От: Dmitriy Igrishin
Дата:
Сообщение: Re: PostgreSQL array, recursion and more
Следующее
От: tv@fuzzy.cz
Дата:
Сообщение: Re: Howto "insert or update" ?