Re: BUG #4684: lastval in function - Mailing list pgsql-bugs

From Heikki Linnakangas
Subject Re: BUG #4684: lastval in function
Date
Msg-id 49AB981A.2050009@enterprisedb.com
Whole thread Raw
In response to BUG #4684: lastval in function  ("andreas" <postgresql@elbrief.de>)
Responses Re: BUG #4684: lastval in function  (Andreas <postgresql@elbrief.de>)
List 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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #4684: lastval in function
Next
From: "Dr. Björn Weitzig"
Date:
Subject: Re: BUG #4638: Bug with Geometry in Array