Re: BUG #4684: lastval in function

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: andreas <postgresql(at)elbrief(dot)de>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4684: lastval in function
Date: 2009-03-02 08:26:02
Message-ID: 49AB981A.2050009@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

andreas wrote:
> if nextval is used inside a function in a insertstatement, you get always
> the value from inside the last function. but i expected, that lastval()
> deliver the value from the insertstatement. i think, this should clearify in
> the documentation, or better fixed that the nextval from an insertstatement
> is called after the functioncalls.

Well, others might expect the opposite, like existing applications. Want
to suggest wording for the documentation?

To get the id of the row inserted, use INSERT RETURNING. Or currval('bla2').

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Dr. Björn Weitzig 2009-03-02 12:33:50 Re: BUG #4638: Bug with Geometry in Array
Previous Message Tom Lane 2009-02-28 16:09:55 Re: BUG #4684: lastval in function