Column value derived from generated column in INSERT?

Поиск
Список
Период
Сортировка
От Mark Raynsford
Тема Column value derived from generated column in INSERT?
Дата
Msg-id 20221019173225.53d939f2@sunflower.int.arc7.info
обсуждение исходный текст
Ответы Re: Column value derived from generated column in INSERT?  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От:
Дата:
Сообщение: RE: Cannot restore windows dump on linux
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Column value derived from generated column in INSERT?