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