Re: update returning order by syntax error question - Mailing list pgsql-general

From Luca Ferrari
Subject Re: update returning order by syntax error question
Date
Msg-id CAKoxK+7DO65FaZ84DYon9tWjPxGhruhOfcLx127=8ifn_KhSsg@mail.gmail.com
Whole thread Raw
In response to update returning order by syntax error question  (raf <raf@raf.org>)
List pgsql-general
On Thu, Sep 12, 2019 at 5:45 AM raf <raf@raf.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



pgsql-general by date:

Previous
From: raf
Date:
Subject: update returning order by syntax error question
Next
From: Achilleas Mantzios
Date:
Subject: Re: pgbouncer with ldap