On Tue, Mar 12, 2013 at 03:49:40PM +0100, Gijs Molenaar wrote:
Hi,
A typical question that is probably asked before, but I can't find an answer in the archives or in the doc.
Is there a SQL function for getting the last inserted ID for a auto increment or serial field? PostgreSQL has lastval(). I know it is returned in the query result, but I need to have the value inside a SQL function. Also I know that if you manually create a sequence for ID generation you can get the next value with:
SELECT NEXT VALUE FOR seq_freq INTO freqid;
But we are trying to keep our queries as generic as possible (close to impossible, but still) hence we want to use the SERIAL type.
Or is there a way to find out what is the name of the sequence made when giving a SERIAL type to a column? The values is returned through the mapi result.
Niels
thanks,
-- Gijs Molenaar http://www.astro.uva.nl/people/gijs-molenaar/
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
-- Niels Nes, Centrum Wiskunde & Informatica (CWI) Science Park 123, 1098 XG Amsterdam, The Netherlands room L3.14, phone ++31 20 592-4098 sip:4098@sip.cwi.nl url: http://www.cwi.nl/~niels e-mail: Niels.Nes@cwi.nl