Re: INSERT ... RETURNING in v8.2

Поиск
Список
Период
Сортировка
От Tom Allison
Тема Re: INSERT ... RETURNING in v8.2
Дата
Msg-id 8E77CF32-BFEF-4254-999B-5104A574D0E7@tacocat.net
обсуждение исходный текст
Ответ на INSERT ... RETURNING in v8.2  (Vincenzo Romano <vincenzo.romano@gmail.com>)
Ответы Re: INSERT ... RETURNING in v8.2
Re: INSERT ... RETURNING in v8.2
Список pgsql-general
On Jun 12, 2007, at 10:18 AM, Vincenzo Romano wrote:

>
> Hi all.
> I'm trying to use this wonderful feature (thanks to anyone who
> suggested/committed/implemented it).
>
> According to the documentation:
> (http://www.postgresql.org/docs/8.2/interactive/sql-insert.html)
>
> "The optional RETURNING clause causes INSERT to compute and return
> value(s) based on each row actually inserted. This is primarily
> useful for obtaining values that were supplied by defaults, such
> as a serial sequence number. However, any expression using the
> table's columns is allowed. The syntax of the RETURNING list is
> identical to that of the output list of SELECT."

Holy Crud!
you mean to tell me I can replace:

insert into table(string) values(('one'),('two'),('three'));
select idx from table where string in ('one','two','three');

with

insert into table(string) values(('one'),('two'),('three')) returning
idx;

?????

I realize that this is an extension to standard SQL but it sure would
save me a lot.

I'm wondering just how many other things I'm missing....
(I am really starting to like this database more every week)

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

Предыдущее
От: "Alfred Zhao"
Дата:
Сообщение: Which meta table contain the functions
Следующее
От: Tom Allison
Дата:
Сообщение: Re: INSERT ... RETURNING in v8.2