From this simple example it is clear that a newly assigned value of a column in an update
sentence cannot simply be reused in other columns assignment.
drop table if exists stocks cascade;
create table stocks (
id serial,
stock_available int,
stock_locked int
);
insert into stocks(stock_available, stock_locked) values
(100, 10),
(100, 10),
(100, 10),
(100, 10),
(100, 10);
update stocks
set stock_available = 5, stock_locked = stock_available + 1;
select * from stocks;
id|stock_available|stock_locked|
--|---------------|------------|
1| 5| 101|
2| 5| 101|
3| 5| 101|
4| 5| 101|
5| 5| 101|
What I am wondering if there is something like excluded
for updates.