automatic update or insert

Поиск
Список
Период
Сортировка
От tobbe
Тема automatic update or insert
Дата
Msg-id 1129790184.351579.302550@g47g2000cwa.googlegroups.com
обсуждение исходный текст
Ответы Re: automatic update or insert  (PFC <lists@boutiquenumerique.com>)
Re: automatic update or insert  (Daryl Richter <daryl@brandywine.com>)
Re: automatic update or insert  (Patrick JACQUOT <patrick.jacquot@anpe.fr>)
Список pgsql-sql
Hi.

I have a little problem.

In a system of mine i need to insert records into table [tbStat], and
if the records exist i need to update them instead and increase a
column [cQuantity] for every update.

I.e. the first insert sets cQuantity to 1, and for every other run
cQuantity is increased.

Currently i have implemented this as a stored procedure in the plpgsql
language. This means that in my stored procedure i first do a select to
find out if the row exists or not, then i do a insert or update
depending if the row existed.

Unfortunately, stored procedures seems awfully slow. And i need the
application to go faster.

One solution could be to implement the stored procedure in my program
instead. I think that this will be atleast 50% faster than my stored
procedure, so that would be ok.

However, this has made me thinking. Couldn't this be done directly in
SQL?


Brgds Robert



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

Предыдущее
От: Sarah Asmaels
Дата:
Сообщение: writable joined view
Следующее
От: Wendell Anderson
Дата:
Сообщение: Article on Oracle & MySQL in E-week