On Nov 27, 2007 12:18 PM, Niels Nes
On Tue, Nov 27, 2007 at 08:16:30PM +0100, Martin Kersten wrote:
Great. Is there a way to ask sequences for the previous value? Or is it only next?
only next.
So if I use SERIAL or AUTOINCREMENT columns, what is the way to get the most recently inserted ID? (Am assumming it's not possible?)
how about a max() over the column?
how about concurrent inserts ;-(
Thanks much for the responses. Sorry to beat a dead horse.... (Am currently in the process of simulating AUTOINC and SERIAL with SEQUENCES as suggested, since the ORM part of SQLAlchemy relies heavily on knowing the id). So let me rephrase my question to try to eliminate the concurrency issue. Is is possible to get the ID of the item I recently inserted (ignoring that others might have inserted them). Perhaps the concurrency can't be eliminated here, since the cursor doesn't know the id, it's all server side. Hope I'm not being too annoying, I'm just trying to understand how things work.