Você já tentou
UPDATE .. FROM não padrão do Postgres cláusula? Eu imagino, isso funcionaria update mytable
set a = first_part(gen.id),
b = second_part(gen.id),
c = third_path(gen.id)
from (
select genid() as genid, id
from mytable
where package_id = 10
) gen
where mytable.id = gen.id;
--and package_id = 10 -- This predicate is no longer necessary as the subquery
-- already filters on package_id, as Erwin mentioned
Observe que estou forçando
genid() para ser chamado exatamente uma vez por registro em mytable dentro da subseleção. Então estou me juntando a mytable e gen usando um id hipotético coluna. Veja a documentação aqui:https://www.postgresql.org/docs/current/interactive /sql-update.html