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

2007-06-17 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes: > Tom Allison escribió: >> 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. > You are wrong -- you can do it, but it is not an

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

2007-06-17 Thread Alvaro Herrera
Tom Allison escribió: > 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; >

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

2007-06-16 Thread PFC
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

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

2007-06-16 Thread Tom Allison
On Jun 12, 2007, at 11:40 AM, Vincenzo Romano wrote: On Tuesday 12 June 2007 16:35:05 Martijn van Oosterhout wrote: On Tue, Jun 12, 2007 at 04:18:32PM +0200, Vincenzo Romano wrote: Well, at least on v8.2.4 I cannot return count(*), that is the number of lines actually inserted into the table

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

2007-06-16 Thread Tom Allison
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 cau

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

2007-06-12 Thread Vincenzo Romano
On Tuesday 12 June 2007 18:26:35 Tom Lane wrote: > Vincenzo Romano <[EMAIL PROTECTED]> writes: > > Second, I'm not using nested statements, but rather a plain > > INSERT ... RETURNING COUNT(*) INTO var (it's inside a PL/PgSQL > > function body). It should not need any GROUP BY as the query is > > p

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

2007-06-12 Thread Tom Lane
Vincenzo Romano <[EMAIL PROTECTED]> writes: > Second, I'm not using nested statements, but rather a plain > INSERT ... RETURNING COUNT(*) INTO var (it's inside a PL/PgSQL > function body). It should not need any GROUP BY as the query is > plain. > Maybe the solution is somewhere in between what yo

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

2007-06-12 Thread Tom Lane
Vincenzo Romano <[EMAIL PROTECTED]> writes: > Well, at least on v8.2.4 I cannot return count(*), that is the > number of lines actually inserted into the table. Nor I can return > any aggregate function of them. > Am I doing anything wrong or is there some missing sentence in the > documentation?

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

2007-06-12 Thread Vincenzo Romano
On Tuesday 12 June 2007 16:35:05 Martijn van Oosterhout wrote: > On Tue, Jun 12, 2007 at 04:18:32PM +0200, Vincenzo Romano wrote: > > Well, at least on v8.2.4 I cannot return count(*), that is the > > number of lines actually inserted into the table. Nor I can > > return any aggregate function of t

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

2007-06-12 Thread Martijn van Oosterhout
On Tue, Jun 12, 2007 at 04:18:32PM +0200, Vincenzo Romano wrote: > Well, at least on v8.2.4 I cannot return count(*), that is the > number of lines actually inserted into the table. Nor I can return > any aggregate function of them. I don't think anybody considered the possibility of using an aggr

[GENERAL] INSERT ... RETURNING in v8.2

2007-06-12 Thread Vincenzo Romano
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 ro