3

Something like this:

DECLARE
c INTEGER;
UPDATE table SET col = (c := col + 1) WHERE id = 1;

This is wrong:

ERROR:  syntax error at or near ":="

how to do it right?

3

Assuming the update only affects one row:

DECLARE
c INTEGER;
UPDATE table SET col = col + 1 WHERE id = 1
  RETURNING col INTO c;

Reference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.