Search Postgresql Archives

Re: INSERT ... RETURNING in v8.2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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)


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux