At 9:45 AM +0100 5/3/01, RDavies@stripped wrote:
>This has the same problems as the SELECT LAST_INSERT_ID() method though.
>If 2 connections (almost) simultaneously attempt an update, they will both
>SELECT the same maximum myID resulting in a duplicated key when the INSERT
>commands are performed, unless there is something I'm missing here?
There is. LAST_INSERT_ID() returns the most recent AUTO_INCREMENT value
generated by queries on the current connection. Values generated by
other clients on other connections are irrelevant. (That is, you can't
get someone else's AUTO_INCREMENT value.)
>
>
>Russ Davies
>Web Technologist
>mda media limited
>
>Tel: +44 (0)161 487 1111 x 2107
>email: rdavies@stripped
>www.mdamedia.co.uk
>
>
>
>
>
> John Calder
><john@stripped>
>
> Sent by:
>To: "Maurice Faeh"
><m.faeh@stripped>
> myodbc-return-3231-RDavies=mdamedia.co.uk@lists
>cc:
>myodbc@stripped
> .mysql.com
>Subject: Re: AW: Some things stopped working with ADO /
>ODBC
>
>
>
>
>
>
> 02/05/01
>21:53
>
>
>
>
>
>
>
>
>
>
>At 13:13 02-05-01 +0200, you wrote:
>In my innocence, and following inherited legacy practice,
>I have not used auto-increment.
>Instead, I have just used an ordinary numerical field and
>read the max value in, added 1 to it, and use that to write.
>Not so elegant but after reading various posts on
>troubles with auto_increment (and not only MySQL)
>I think I'll stick to it.
>
>I hope the following syntax is correct, I'm just writing
>from memory here, but this should give the idea.
>
>Set rst = con.Execute("SELECT myID FROM myTable ORDER BY myID DESC LIMIT
>1")
>nID = rst.Fields(0) + 1
>
>
>________________________________________________________________
>
>John Calder, PixieProgrammer
>http://www.pixieware.com
>"Technology to revitalise your text-based host apps"
>________________________________________________________________
--
Paul DuBois, paul@stripped