Re: insert rowtype

Поиск
Список
Период
Сортировка
От Christoph Haller
Тема Re: insert rowtype
Дата
Msg-id 3EBF5E6D.5886CD73@rodos.fzk.de
обсуждение исходный текст
Ответ на insert rowtype  (Bryan Klimt <Bryan_Klimt@baylor.edu>)
Список pgsql-sql
>
> create or replace function updatetest(integer,varchar(32)) returns
> integer as
>       '
>       declare
>               -- the oid of the new row
>               newoid integer;
>       begin
>               -- duplicate the row
>               insert into test
>                       select * from test t where
>                               t.tmstamp=(
>                                       select max(tt.tmstamp) from test
tt where tt.id=t.id
>                               )
>                               and t.id=$1;
>
>               -- get the oid of the new duplicate
>               get diagnostics newoid = result_oid;
>
>               -- update the columns you want to change
>               update test set tmstamp=$2 where oid=newoid;
>
>               -- return the new oid
>               return newoid;
>       end;
>       ' language plpgsql;
>
I only want to mention, this would insert multiple rows if the WHERE
conditions do not specifiy a single row.
Regards, Christoph



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

Предыдущее
От: Peter Childs
Дата:
Сообщение: Re: Constraint Syntax Question
Следующее
От: Lucas Lain
Дата:
Сообщение: Re: epoch to timestamp