Re: INSERT ... RETURNING in v8.2 - Mailing list pgsql-general

From Tom Allison
Subject Re: INSERT ... RETURNING in v8.2
Date
Msg-id 8E77CF32-BFEF-4254-999B-5104A574D0E7@tacocat.net
Whole thread Raw
In response to INSERT ... RETURNING in v8.2  (Vincenzo Romano <vincenzo.romano@gmail.com>)
Responses Re: INSERT ... RETURNING in v8.2  (PFC <lists@peufeu.com>)
Re: INSERT ... RETURNING in v8.2  (Alvaro Herrera <alvherre@commandprompt.com>)
List 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 by date:

Previous
From: "Alfred Zhao"
Date:
Subject: Which meta table contain the functions
Next
From: Tom Allison
Date:
Subject: Re: INSERT ... RETURNING in v8.2