List:MySQL ODBC« Previous MessageNext Message »
From:Paul DuBois Date:May 5 2001 10:37pm
Subject:Re: AW: Some things stopped working with ADO / ODBC
View as plain text  
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
Thread
AW: Some things stopped working with ADO / ODBCMaurice Faeh2 May
  • Re: AW: Some things stopped working with ADO / ODBCPete French2 May
  • Re: Some things stopped working with ADO / ODBCPeterWR2 May
    • AW: Some things stopped working with ADO / ODBCMaurice Faeh2 May
  • Re: AW: Some things stopped working with ADO / ODBCFredrick Bartlett3 May
    • AW: AW: Some things stopped working with ADO / ODBCMaurice Faeh3 May
RE: Some things stopped working with ADO / ODBCMAR Bosschaert2 May
  • AW: Some things stopped working with ADO / ODBCMaurice Faeh2 May
AW: Some things stopped working with ADO / ODBCMaurice Faeh2 May
RE: AW: Some things stopped working with ADO / ODBCJulian Strickland2 May
  • RE: AW: Some things stopped working with ADO / ODBCPete French2 May
  • Re: AW: Some things stopped working with ADO / ODBCPeterWR2 May
RE: Some things stopped working with ADO / ODBCMAR Bosschaert2 May
RE: AW: Some things stopped working with ADO / ODBCJulian Strickland2 May
  • RE: AW: Some things stopped working with ADO / ODBCPete French2 May
Re: AW: Some things stopped working with ADO / ODBCJohn Calder2 May
Re: AW: Some things stopped working with ADO / ODBCRDavies3 May
  • Re: AW: Some things stopped working with ADO / ODBCPaul DuBois6 May
Re: AW: Some things stopped working with ADO / ODBCJohn Calder3 May
  • Re: AW: Some things stopped working with ADO / ODBCHarald Kapper3 May
    • SELECT...WHERE auto_id IS NULL (Was: Re: AW: Some things stopped working with ADO / ODBC)Joshua J. Kugler4 May
      • AW: SELECT...WHERE auto_id IS NULL (Was: Re: AW: Some things stopped working with ADO / ODBC)Maurice Faeh5 May
    • SELECT...WHERE auto_id IS NULL (Was: Re: AW: Some things stopped working with ADO / ODBC)Joshua J. Kugler4 May