[gameprogrammer] Re: Slightly offtopic: SQL Command

Can you open a transaction, insert, then select back the max THEN commit the transaction? If you have a transaction open on a table, won't the database not allow any updates until the transaction has been committed?


Olivier Delannoy wrote:
Kevins is there several thread accessing the database at the same time ?
if not you can simply do select max(uid) from table; and insert with
the next available uid.


On 11/1/06, Sami Näätänen <sn.ml@xxxxxxxxxxxx> wrote:
On Tuesday 31 October 2006 18:25, Kevin Jenkins wrote:
> 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?

INSERT.

> >> 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

---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html






--
Jacob Briggs
Systems Engineer

Core Technology Limited
Level 1, NZX Centre
11 Cable Street
Wellington
Phone +64 4 801 2252

--

object doAnythingConceivable(string whatToDo, object whatToDoItWith) { .....



---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: