2013-05-02 44 views
0

我正在尋找在PostgreSQL的優化的方法,這樣做:我怎麼能在PostgreSQL上指定一個多字段功能結果更新

update table1 
set (a,b)=(somecomplexfunction(table1.something),2*somecomplexfunction(table1.something)) 
where ... 

這算somecomplexfunction(table1.something)兩次,我d喜歡做這樣的事情:

update table1 set (a,b)=somecomplexvectorfunction(table1.something) where ... 

但更新語法不支持多個字段功能。有任何想法嗎?

回答

1
update table1 
set 
    a = somecomplexfunction(table1.something), 
    b = a * 2 
where ... 
+0

是不是「a」舊時「我」加倍了? – 2013-05-22 16:03:12