Re: functions: stable/volatile

Поиск
Список
Период
Сортировка
От Tomasz Ostrowski
Тема Re: functions: stable/volatile
Дата
Msg-id 20061120155901.GE29319@batory.org.pl
обсуждение исходный текст
Ответ на functions: stable/volatile  (Rafal Pietrak <rafal@zorro.isa-geek.com>)
Ответы Re: functions: stable/volatile
Список pgsql-general
On Mon, 20 Nov 2006, Rafal Pietrak wrote:

> The most obvious construct I'd use is:
>         UPDATE my_table set filed=newvalue WHERE
>                  my_function(input)=my_table.selector_field;
> but it's useless, since the function would have been be evaluated for
> every row of the table.

-- Not tested

create function update_my_table(newvalue, input)
    returns void
    volatile
    language plpgsql
as $$
declare
    selector selector_field_type;
begin
    selector := my_function(input);
    update my_table set filed=newvalue
        where my_table.selector_field=selector;
end;
$$;

-- and then

select update_my_table(newvalue, input);

-- Not tested.

Regards
Tometzky
--
...although Eating Honey was a very good thing to do, there was a
moment just before you began to eat it which was better than when you
were...
                                                      Winnie the Pooh

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

Предыдущее
От: "Frank Millman"
Дата:
Сообщение: pg_get_serial_sequence is inconsistent
Следующее
От: Vivek Khera
Дата:
Сообщение: Re: Eliminating bad characters from a database for upgrading from 7.4 to 8.1