Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-bugs by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group