Re: connecting multiple INSERT CTEs to same record? - Mailing list pgsql-general

From David G. Johnston
Subject Re: connecting multiple INSERT CTEs to same record?
Date
Msg-id CAKFQuwatrODxE48RrZkvxia3Jb9YyDsobpVME7FzPfhB1SL4HQ@mail.gmail.com
Whole thread Raw
In response to connecting multiple INSERT CTEs to same record?  (Assaf Gordon <assafgordon@gmail.com>)
Responses Re: connecting multiple INSERT CTEs to same record?
List pgsql-general
On Tuesday, October 19, 2021, Assaf Gordon <assafgordon@gmail.com> wrote:

Sadly, I can't assume the student name is unique, so I can't "join" on it.


Instead of assigning a unique identifier to student after inserting it into the table, assign the identifier first.  Generally this is done by using “nextval()” explicitly in a manner similar to how it is used when computing the default for the serial column.  Then you can return/join on the identifier reliably and not worry about duplicate student names.

David J.

pgsql-general by date:

Previous
From: Bryn Llewellyn
Date:
Subject: Re: Where is the tsrange() function documented?
Next
From: Kristjan Mustkivi
Date:
Subject: How to rename in-use logical replication publication?