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

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


of interest, cont.

-------- Original Message --------
Subject: 	Re: [GENERAL] INSERT ... RETURNING in v8.2
Date: 	Sat, 16 Jun 2007 18:04:08 +0200
From: 	PFC <lists at peufeu.com>
To: 	Tom Allison <tom at tacocat.net>, Vincenzo Romano 
<vincenzo.romano at gmail.com>
CC: 	pgsql-general at postgresql.org
References: 	<200706121618.32613.vincenzo.romano at gmail.com> 
<8E77CF32-BFEF-4254-999B-5104A574D0E7 at tacocat.net>



> 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');

	Yes.

	A smart ORM library should, when you create a new database object from  
form values, use INSERT RETURNING to grab all the default values (SERIALs,  
DEFAULTs, trigger-generated stuff etc). This is much more elegant than  
digging to find the sequence name to currval() it !

	I think this feature is priceless (but it would be even better if I could  
do INSERT INTO archive (DELETE FROM active WHERE blah RETURNING *)

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings



More information about the Nitro-general mailing list