Re: Guidance on INSERT RETURNING order

From: Achilleas Mantzios <a(dot)mantzios(at)cloud(dot)gatewaynet(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Guidance on INSERT RETURNING order
Date: 2023-04-11 20:17:43
Message-ID: e6bd70b4-83a9-38d2-026d-e082f0896282@cloud.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Στις 11/4/23 23:06, ο/η Adrian Klaver έγραψε:
> On 4/11/23 12:47, Federico wrote:
>> Hello list,
>>
> https://www.sqlite.org/lang_returning.html#limitations_and_caveats
>>
>> Searching the archive seems that a using the INSERT SELECT ORDER BY
>> form should be a better solution,
>> so the above insert should be rewritten as
>>
>>      INSERT INTO t(data)
>>      SELECT data FROM (VALUES ('a', 1), ('b', 2), ('c', 3)) as vv(data,
>> num) ORDER BY num
>>      RETURNING id
>
> Or
>
> with i as (INSERT INTO t(data) VALUES ('a', 1), ('b', 2), ('c', 3)
> returning id)
> select i.id from i order by id;
+1 for this version!
>
>> Sorry for the long email,
>> Thanks
>>
>>      Federico
>>
>>
>
--
Achilleas Mantzios
IT DEV - HEAD
IT DEPT
Dynacom Tankers Mgmt

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2023-04-11 20:22:27 Re: Guidance on INSERT RETURNING order
Previous Message Adrian Klaver 2023-04-11 20:06:45 Re: Guidance on INSERT RETURNING order