Re: Example of RETURNING clause to get auto-generated keys - Mailing list pgsql-general

From Ken Johanson
Subject Re: Example of RETURNING clause to get auto-generated keys
Date
Msg-id 45B80F1B.4030602@kensystem.com
Whole thread Raw
In response to Re: Example of RETURNING clause to get auto-generated keys from INSERT  ("Adam Rich" <adam.r@sbcglobal.net>)
Responses Re: Example of RETURNING clause to get auto-generated keys  (Ken Johanson <pg-user@kensystem.com>)
List pgsql-general
Adam Rich wrote:
> Let's say you have a table with "id, value" columns.
>
> And your normal query would be this:
>
> INSERT into mytable (id,value) values (1,"foo"),(2,"bar");
>
> Your new query would be like this:
>
> INSERT into mytable (id,value) values (1,"foo"),(2,"bar")
> RETURNING id;
>
> And you would get a result back with one column (id) and
> two rows (the newly inserted keys).  You can also return
> other fields if you like, you're not limited to just the
> generated keys.
>


Thank you Alvaro and Adam,

Now playing devil's advocate, can anyone see scenarios where this will
not work as expected? Examples (descriptions not sql necessarily) of
those would be helpful too...

Ken



pgsql-general by date:

Previous
From: Rich Shepard
Date:
Subject: Re: Cannot Restart PostgreSQL-8.1.4
Next
From: Ken Johanson
Date:
Subject: Re: Example of RETURNING clause to get auto-generated keys