[Nitro] [Fwd: Re: [GENERAL] INSERT ... RETURNING in v8.2]

Reid Thompson reid.thompson at ateb.com
Sat Jun 16 23:27:28 EDT 2007


of interest...

-------- Original Message --------
Subject: 	Re: [GENERAL] INSERT ... RETURNING in v8.2
Date: 	Sat, 16 Jun 2007 08:02:41 -0400
From: 	Tom Allison <tom at tacocat.net>
To: 	Vincenzo Romano <vincenzo.romano at gmail.com>
CC: 	pgsql-general at postgresql.org
References: 	<200706121618.32613.vincenzo.romano at gmail.com>



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)

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend



More information about the Nitro-general mailing list