Re: update returning order by syntax error question

From: Luca Ferrari <fluca1978(at)gmail(dot)com>
To: raf <raf(at)raf(dot)org>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: update returning order by syntax error question
Date: 2019-09-12 05:33:55
Message-ID: CAKoxK+7DO65FaZ84DYon9tWjPxGhruhOfcLx127=8ifn_KhSsg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Sep 12, 2019 at 5:45 AM raf <raf(at)raf(dot)org> wrote:
> ERROR: syntax error at or near "t"
> LINE 2: tblname t

This works on 9.6.9 and 11.4:

luca=> with u as ( update t_all set id = 5 where id <= 5 returning *)
select * from u;
id | ref_id
----+--------
5 | 1
(1 row)

luca=> select version();
version
--------------------------------------------------------------------------------------------------
PostgreSQL 9.6.9 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu
7.2.0-8ubuntu3.2) 7.2.0, 64-bit
(1 row)

However, I know for sure that UPDATE has some restrictions on the
table aliasing (at least, they are not used as for a SELECT), so the
problem could be in the real query you are executing.
It works with or without the order by.

Luca

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Achilleas Mantzios 2019-09-12 05:51:48 Re: pgbouncer with ldap
Previous Message raf 2019-09-12 03:17:43 update returning order by syntax error question