M
M
Mikhail Antipov2015-10-14 18:47:47
PostgreSQL
Mikhail Antipov, 2015-10-14 18:47:47

How to save data to a variable in an UPDATE query in a PostgreSQL function?

As it is correct to save the data in a variable in plpgsql, I try so:
DECLARE
c INTEGER;
UPDATE table SET col = (c := col + 1) WHERE id = 1;
(further variable "c" is used in other queries)
Error:
ERROR: syntax error at or near ":="

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Kosmodemyansky, 2015-10-14
@Jugga

UPDATE ... returning
www.postgresql.org/docs/9.4/static/sql-update.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question