[gameprogrammer] Re: Slightly offtopic: SQL Command
- From: Kevin Jenkins <gameprogrammer@xxxxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Tue, 31 Oct 2006 08:25:41 -0800
Sami, you said that PostgreSQL returns the oid of the inserted tuple.
Are you referring to the INSERT command, or the SELECT command
pointed out there?
For MySQL, you'd use
SELECT LAST_INSERT_ID()
For Transact-SQL (used by SQL Server and Sybase), you'd use
SELECT SCOPE_IDENTITY()
For PostgreSQL, you'd use
SELECT CURRVAL('tablename_columnname_seq')
PostgreSQL at least returns the oid of the inserted tuple.
This of course is unique. This can be used to get any auto_increment etc
stuff whit ease. So check the behaviour of the DB you use. It can
provide some similar way to get that.
PS. How it seams that every time I encounter new DB system PostgreSQL
seams to do things right or better. :) Or maybe I'm a litle bit biased
to PostgreSQL. ;)
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- References:
- [gameprogrammer] Gaming industry - how prevalent?
- From: Alan Wolfe
- [gameprogrammer] Slightly offtopic: SQL Command
- From: Kevin Jenkins
- [gameprogrammer] Re: Slightly offtopic: SQL Command
- From: Matthew Weigel
- [gameprogrammer] Re: Slightly offtopic: SQL Command
- From: Sami Näätänen
Other related posts:
- » [gameprogrammer] Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
For MySQL, you'd use SELECT LAST_INSERT_ID()
For Transact-SQL (used by SQL Server and Sybase), you'd use SELECT SCOPE_IDENTITY()
For PostgreSQL, you'd use SELECT CURRVAL('tablename_columnname_seq')
PostgreSQL at least returns the oid of the inserted tuple.
This of course is unique. This can be used to get any auto_increment etc stuff whit ease. So check the behaviour of the DB you use. It can provide some similar way to get that.
PS. How it seams that every time I encounter new DB system PostgreSQL seams to do things right or better. :) Or maybe I'm a litle bit biased to PostgreSQL. ;)
--------------------- To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- [gameprogrammer] Gaming industry - how prevalent?
- From: Alan Wolfe
- [gameprogrammer] Slightly offtopic: SQL Command
- From: Kevin Jenkins
- [gameprogrammer] Re: Slightly offtopic: SQL Command
- From: Matthew Weigel
- [gameprogrammer] Re: Slightly offtopic: SQL Command
- From: Sami Näätänen