This is the query that I'm trying to run to update multiple rows by their ID in one single string. I'm using AWS Redshift (which is based on a very old version of PostgreSQL):
UPDATE promotion
SET engagements = c.engagements
FROM (VALUES (668, 73), (684, 135), (680, 73), (672, 76), (682, 94),
(676, 4), (670, 81), (686, 104), (678, 1), (674, 0)
) AS c(id, engagements)
WHERE c.id = promotion.id;
And this is the error being produced:
sqlalchemy.exc.ProgrammingError: (pg8000.core.ProgrammingError) (u'ERROR',
u'42601', u'syntax error at or near ","', u'72', u'/home/ec2-
user/padb/src/pg/src/backend/parser/parser_scan.l', u'699', u'yyerror', u'',
u'')
[SQL: 'UPDATE promotion SET engagements = c.engagements FROM (VALUES
(668, 73), (684, 135), (680, 73), (672, 76), (682, 94), (676, 4), (670, 81),
(686, 104), (678, 1), (674, 0)) AS c(id, engagements) WHERE c.id =
promotion.id;']
EDIT: Using query format from answer here: Update multiple rows in same query using PostgreSQL