Re: SQL-question: returning the id of an insert querry

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Doug McNaught <doug(at)mcnaught(dot)org>
Cc: scott_list(at)mischko(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: SQL-question: returning the id of an insert querry
Date: 2003-11-12 22:38:31
Message-ID: 29036.1068676711@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Doug McNaught <doug(at)mcnaught(dot)org> writes:
> Scott Chapman <scott_list(at)mischko(dot)com> writes:
>> What's the process to suggest changes to PG along these lines? Say, a
>> proposal to make it configurable for a user to have a INSERT return the
>> primary key that it just inserted rather than what it returns now?

> What if you have a multicolumn PK?

Or a PK that's not an integer? Or no PK at all?

There's not likely to be any interest in hotwiring INSERT to return
a different command tag than it does now; that would break too much
existing code. There has been some talk of inventing an "INSERT
... RETURNING ..." syntax extension that would return whatever
expressions you cared to compute from inserted rows --- but in the form
of a SELECT result, not by trying to squeeze it into a command tag.
I think the last discussion of this was a year or so back in pg-hackers.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-11-12 23:01:14 Re: how can I change a btree index into a hash index?
Previous Message Jan Wieck 2003-11-12 22:36:12 Re: serial type vs. sequences