Re: Example of RETURNING clause to get auto-generated keys

Поиск
Список
Период
Сортировка
От Ken Johanson
Тема Re: Example of RETURNING clause to get auto-generated keys
Дата
Msg-id 45B80F1B.4030602@kensystem.com
обсуждение исходный текст
Ответ на Re: Example of RETURNING clause to get auto-generated keys from INSERT  ("Adam Rich" <adam.r@sbcglobal.net>)
Ответы Re: Example of RETURNING clause to get auto-generated keys  (Ken Johanson <pg-user@kensystem.com>)
Список pgsql-general
Adam Rich wrote:
> Let's say you have a table with "id, value" columns.
>
> And your normal query would be this:
>
> INSERT into mytable (id,value) values (1,"foo"),(2,"bar");
>
> Your new query would be like this:
>
> INSERT into mytable (id,value) values (1,"foo"),(2,"bar")
> RETURNING id;
>
> And you would get a result back with one column (id) and
> two rows (the newly inserted keys).  You can also return
> other fields if you like, you're not limited to just the
> generated keys.
>


Thank you Alvaro and Adam,

Now playing devil's advocate, can anyone see scenarios where this will
not work as expected? Examples (descriptions not sql necessarily) of
those would be helpful too...

Ken



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

Предыдущее
От: Rich Shepard
Дата:
Сообщение: Re: Cannot Restart PostgreSQL-8.1.4
Следующее
От: Ken Johanson
Дата:
Сообщение: Re: Example of RETURNING clause to get auto-generated keys