On Tue, Nov 27, 2007 at 10:46:06PM +0100, Niels Nes wrote:
On Tue, Nov 27, 2007 at 09:27:20PM +0100, Fabian Groffen wrote:
On 27-11-2007 13:13:13 -0700, m h wrote:
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.
As far as I am aware, the problem should be solved in the same was as it is done for PostgreSQL, as it uses the same (SQL standard) strategy. Last time I checked, they didn't have a method either to retrieve the last id value.
I don't know if we have currval() implemented, but I guess we could, and it might solve your problem at this level.
http://www.postgresql.org/docs/7.4/interactive/functions-sequence.html
Probably he want (needs)
PQoidValue
Returns the OID of the inserted row, if the SQL command was an INSERT that inserted exactly one row into a table that has OIDs. Otherwise, returns InvalidOid.
Oid PQoidValue(const PGresult *res);
I guess this could be a feature request ;-)
or the mysql Method insert_id int insert_id() Description Returns the id of the last INSERT query into a table with an AUTO INCREMENT field. Niels
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
--
Niels Nes, Centre for Mathematics and Computer Science (CWI) Kruislaan 413, 1098 SJ Amsterdam, The Netherlands room C0.02, phone ++31 20 592-4098, fax ++31 20 592-4312 url: http://www.cwi.nl/~niels e-mail: Niels.Nes@cwi.nl
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
-- Niels Nes, Centre for Mathematics and Computer Science (CWI) Kruislaan 413, 1098 SJ Amsterdam, The Netherlands room C0.02, phone ++31 20 592-4098, fax ++31 20 592-4312 url: http://www.cwi.nl/~niels e-mail: Niels.Nes@cwi.nl