Search Postgresql Archives

Re: functions: stable/volatile

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux