RE: INSERT [IGNORE] INTO TABLE

Поиск
Список
Период
Сортировка
От Edmar Wiggers
Тема RE: INSERT [IGNORE] INTO TABLE
Дата
Msg-id NEBBIAKDCDHFGJMLHCKIEENACAAA.edmar@brasmap.com
обсуждение исходный текст
Ответ на RE: INSERT [IGNORE] INTO TABLE  (Petr Jezek <jez20um@axpsu.fpf.slu.cz>)
Список pgsql-sql
> > Check existence and then insert or update. If you want, I guess
> you could
> > wrap that inside a stored procedure.
> >
>     Well, that's a good idea :-) but I'm not sure about how to create
>     such procedure. I would appreciate Your help.

Quite frankly, I'm not sure either. I'm just starting with PostgreSQL, what
I really know is Oracle. I believe it would be something like

...
[declare routine, with one argument per record field]
...
if exists(select 1 from table_name where [field_key] = [arg_key]) then update table_name  set field1 = arg1,...,fieldn
=argn  where field_key = arg_key;
 
else insert into table_name (field1,...,fieldn) values (arg1,...,argn);
end if;
...

The syntax is probably off, but that's the idea. I used that several times
on oracle.



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

Предыдущее
От: Petr Jezek
Дата:
Сообщение: RE: INSERT [IGNORE] INTO TABLE
Следующее
От: Najm Hashmi
Дата:
Сообщение: Re: INSERT [IGNORE] INTO TABLE