Answer the question
In order to leave comments, you need to log in
Is there a difference between an expression and a transaction?
If two requests (read and update) occur within the same READ COMMITED transaction, then, of course, we cannot be sure that the update will definitely occur. The data may have changed in another transaction.
How about one expression? Judging from the documentation, the same lines are visible inside the expression. Can we be sure that the update will definitely happen in the next construction (we assume that SELECT returned some data)?
WITH t (
SELECT id
FROM test
WHERE (id = 1) AND (value = 2)
RETURNING id
)
UPDATE test
SET value = 3
FROM t
WHERE
(test.id = t.id)
AND (t.value = t.value)
Answer the question
In order to leave comments, you need to log in
Can we be sure that the update will definitely happen in the next construction (we assume that SELECT returned some data)?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question