I need to write a plpgsql function which executes update statement in an infinite loop:
create function change_type() returns void as $$
begin
loop
update table a set type = 1 where date < now();
end loop;
end;
$$ LANGUAGE plpgsql;
When I call this function the update statement is not executed, although I can see that the loop is running. I ran the update statement as a single query and it works. How can I solve this problem?
Thanks