Postgresql Update with 'Returning clause'

455 views
Skip to first unread message

Gary Malouf

unread,
Aug 8, 2015, 1:14:45 AM8/8/15
to H2 Database
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


Noel Grandin

unread,
Aug 10, 2015, 1:55:23 AM8/10/15
to H2 Database
Sorry, we don't support that syntax.
--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages