[SQL] Unable to use INSERT ... RETURNING with column from other table

Поиск
Список
Период
Сортировка
От Andreas Joseph Krogh
Тема [SQL] Unable to use INSERT ... RETURNING with column from other table
Дата
Msg-id VisenaEmail.5d.3c4f083000723eca.15f50641885@tc7-visena
обсуждение исходный текст
Ответы Re: [SQL] Unable to use INSERT ... RETURNING with column from other table  (Peter Geoghegan <pg@bowt.ie>)
Список pgsql-sql
Hi.
 
I'm having this schema:
 
create table foo(   id integer PRIMARY KEY,   name varchar not null
);

insert into foo(id, name) values(1, 'one'), (2, 'two');

insert into foo(id, name) select 3, f.name from foo f where f.id = 1 returning id, f.id;

ERROR:  missing FROM-clause entry for table "f" 
LINE 1: ...lect 3, f.name from foo f where f.id = 1 returning id, f.id;

I'd like to return f.id and the inserted id, is this possible?
 
I want this because I'm hoping to use this in a CTE where other selects from this CTE will use this extra column.
 
Thanks.
 
--
Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963

В списке pgsql-sql по дате отправления:

Предыдущее
От: Klaus Kaisersberger
Дата:
Сообщение: Re: [SQL] How to get the list of tables with encrypted columns
Следующее
От: Peter Geoghegan
Дата:
Сообщение: Re: [SQL] Unable to use INSERT ... RETURNING with column from other table