Re: Column value derived from generated column in INSERT?

2022-10-19 Thread David G. Johnston
On Wed, Oct 19, 2022 at 12:34 PM Mark Raynsford wrote: > On 2022-10-19T11:58:07 -0700 > "David G. Johnston" wrote: > > > On Wed, Oct 19, 2022 at 10:36 AM Mark Raynsford < > co+org.postgre...@io7m.com> > > wrote: > > > > > insert into t (y) values (t.x * 2); > > > > > > I can think of various w

Re: Column value derived from generated column in INSERT?

2022-10-19 Thread Erik Wienhold
> On 19/10/2022 23:51 CEST Adrian Klaver wrote: > > On 10/19/22 12:58 PM, Adrian Klaver wrote: > > On 10/19/22 12:48, Mark Raynsford wrote: > >> On 2022-10-19T12:43:31 -0700 > >> Adrian Klaver wrote: > >>> > >>> HINT:  There is an entry for table "t", but it cannot be referenced from > >>> this p

Re: Column value derived from generated column in INSERT?

2022-10-19 Thread Adrian Klaver
On 10/19/22 12:58 PM, Adrian Klaver wrote: On 10/19/22 12:48, Mark Raynsford wrote: On 2022-10-19T12:43:31 -0700 Adrian Klaver wrote: HINT:  There is an entry for table "t", but it cannot be referenced from this part of the query. HINT:  There is a column named "x" in table "t", but it canno

Re: Column value derived from generated column in INSERT?

2022-10-19 Thread Adrian Klaver
On 10/19/22 12:48, Mark Raynsford wrote: On 2022-10-19T12:43:31 -0700 Adrian Klaver wrote: HINT: There is an entry for table "t", but it cannot be referenced from this part of the query. HINT: There is a column named "x" in table "t", but it cannot be referenced from this part of the query.

Re: Column value derived from generated column in INSERT?

2022-10-19 Thread Mark Raynsford
On 2022-10-19T12:43:31 -0700 Adrian Klaver wrote: > > HINT: There is an entry for table "t", but it cannot be referenced from > this part of the query. > > HINT: There is a column named "x" in table "t", but it cannot be > referenced from this part of the query. Yes, I saw those, hence asking

Re: Column value derived from generated column in INSERT?

2022-10-19 Thread Adrian Klaver
On 10/19/22 12:30, Mark Raynsford wrote: On 2022-10-19T11:58:07 -0700 "David G. Johnston" wrote: On Wed, Oct 19, 2022 at 10:36 AM Mark Raynsford wrote: insert into t (y) values (t.x * 2); I can think of various ways to do it with multiple statements, but a single statement would be pref

Re: Column value derived from generated column in INSERT?

2022-10-19 Thread Mark Raynsford
On 2022-10-19T11:58:07 -0700 "David G. Johnston" wrote: > On Wed, Oct 19, 2022 at 10:36 AM Mark Raynsford > wrote: > > > insert into t (y) values (t.x * 2); > > > > I can think of various ways to do it with multiple statements, but a > > single statement would be preferable. > > > > > No, b

Re: Column value derived from generated column in INSERT?

2022-10-19 Thread David G. Johnston
On Wed, Oct 19, 2022 at 10:36 AM Mark Raynsford wrote: > insert into t (y) values (t.x * 2); > > I can think of various ways to do it with multiple statements, but a > single statement would be preferable. > > No, by extension of the documented constraint: "The generation expression can refer t

Column value derived from generated column in INSERT?

2022-10-19 Thread Mark Raynsford
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 comple