Re: Guidance on INSERT RETURNING order - Mailing list pgsql-general

From Thorsten Glaser
Subject Re: Guidance on INSERT RETURNING order
Date
Msg-id c422c4ef-a284-e45e-b968-27bff221e993@evolvis.org
Whole thread Raw
In response to Re: Guidance on INSERT RETURNING order  (Kirk Wolak <wolakk@gmail.com>)
Responses Re: Guidance on INSERT RETURNING order
Re: Guidance on INSERT RETURNING order
List pgsql-general
On Wed, 12 Apr 2023, Kirk Wolak wrote:

>The solution exists.  Pre-fetch the IDs, assign them and insert them with
>the IDs.  Then you have 100% control.
>SELECT NEXTVAL('tbl_seq') from GENERATE_SERIES(1, <total_needed>);

This would be a nice solution… but the PK could be always generated,
or not even sequential (UUIDs for example). If you’re developing
schema-first the application would not even (need to) know about how
the IDs are generated as it’s the DB that generates them.

AIUI the OP’s an SQLAlchemy developer, which is an ORM. Therefore he
needs a generic solution.

bye,
//mirabilos
--
15:41⎜<Lo-lan-do:#fusionforge> Somebody write a testsuite for helloworld :-)



pgsql-general by date:

Previous
From: Kirk Wolak
Date:
Subject: Re: Guidance on INSERT RETURNING order
Next
From: Rob Sargent
Date:
Subject: Re: Guidance on INSERT RETURNING order