Re: Need magic for inserting in 2 tables

Поиск
Список
Период
Сортировка
От Scott Marlowe
Тема Re: Need magic for inserting in 2 tables
Дата
Msg-id AANLkTi=SR8H53MiCy9Pa2MPoLHeRyD0r3EeTYZAqMzUR@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Need magic for inserting in 2 tables  (Andreas <maps.on@gmx.net>)
Список pgsql-sql
On Sun, Oct 3, 2010 at 8:31 PM, Andreas <maps.on@gmx.net> wrote:
>
> insert into t1_t2 ( fk_1, fk_2 )
>    insert into table_1 ( txt )
>    values ( 'A' ), ( 'B' ), ( 'C' )
>    returning id_1, 42;
>
> The inner insert works and dumps the inserted ids along with the constant
> which is needed in the outer insert as reference to the project.
>
> Both inserts run together give an error.

Yeah, it's not capable of directly feeding the next insert like that.
You run the first insert, get the results back, then cycle through
them in your code to make the new inserts based on that.


--
To understand recursion, one must first understand recursion.


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

Предыдущее
От: Andreas
Дата:
Сообщение: Re: Need magic for inserting in 2 tables
Следующее
От: Joshua Tolley
Дата:
Сообщение: Re: join returns too many results...