Re: connecting multiple INSERT CTEs to same record?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Assaf Gordon <assafgordon(at)gmail(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: connecting multiple INSERT CTEs to same record?
Date: 2021-10-19 19:13:44
Message-ID: CAKFQuwatrODxE48RrZkvxia3Jb9YyDsobpVME7FzPfhB1SL4HQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tuesday, October 19, 2021, Assaf Gordon <assafgordon(at)gmail(dot)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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kristjan Mustkivi 2021-10-19 19:31:42 How to rename in-use logical replication publication?
Previous Message Bryn Llewellyn 2021-10-19 17:59:40 Re: Where is the tsrange() function documented?