Column value derived from generated column in INSERT? - Mailing list pgsql-general

From Mark Raynsford
Subject Column value derived from generated column in INSERT?
Date
Msg-id 20221019173225.53d939f2@sunflower.int.arc7.info
Whole thread Raw
Responses Re: Column value derived from generated column in INSERT?
List pgsql-general
Hello!

I'd like to be able to do something sort of analogous to this:

  create table t (
    x integer not null generated always as identity, 
    y integer not null
  );

  insert into t (y) values (t.x * 2);

In the real project, the "t.x * 2" expression is obviously something
a lot more complex, but I think it illustrates the point: I'd like to
be able to refer to the generated value of a column within the INSERT
statement that's going to cause it to be generated. Is there a way to
do this with a single statement right now?

I can think of various ways to do it with multiple statements, but a
single statement would be preferable.

-- 
Mark Raynsford | https://www.io7m.com




pgsql-general by date:

Previous
From:
Date:
Subject: RE: Cannot restore windows dump on linux
Next
From: "David G. Johnston"
Date:
Subject: Re: Column value derived from generated column in INSERT?