I'm trying to execute the following against an h2database in postgresql compatibility mode:
UPDATE ctable c
SET c.status = 1
FROM (
SELECT co.id
FROM ctable co
INNER JOIN htable a
ON a.id = secretId
AND a.coupon_group_id = co.coupon_group_id
AND a.status = 1
WHERE co.status = 0
LIMIT 1
FOR UPDATE
) ic
WHERE c.id = ic.id
RETURNING c.code
Against Postgres, this performs an update and returns a field from the row that was updated. When I try to execute this against an h2database, I am getting a mysterious syntax error [42000-187].
This syntax is inspired by http://dba.stackexchange.com/questions/69471/postgres-update-limit-1