Re: Re: Get Last ID Inserted

From: Date: Thu, 21 Nov 2002 16:27:17 +0000
Subject: Re: Re: Get Last ID Inserted
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-23569@lists.php.net to get a copy of this message
Please don't ban more for this example using VB, but this is how I did it a while ago in VB/ASP, generating and setting the RecID in one stroke. I assume you could just wrap this in PHP and it would work just as well.
       strSQL="Select newid()"
       RecID = objConn.Execute(strSQL)(0).value
Ryan Marrs wrote:
I do see that picking up the incorrect ID, which is why we created a stored procedure which returned the affected row. -----Original Message----- From: Adam Voigt [mailto:adam@cryptocomm.com] Sent: Thursday, November 21, 2002 11:13 AM To: David Elliott Cc: Adam Voigt on PHP-DB Subject: Re: [PHP-DB] Re: Get Last ID Inserted But if there are heavy operations on the site, will this not also pick up a different last inserted id, if in the split milisecond between the insert and the next mssql_query which has the @@identity say, another user does an insert? On Thu, 2002-11-21 at 11:03, David Elliott wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello Adam On 21 November 2002 at 10:47:15 -0500 (which was 15:47 where I live) Adam Voigt wrote
Using Microsoft SQL does anyone know how to get the id of the row that you just inserted without clumsily trying to select the id back based on the same criteria of your insert (which might be overlapping)?
     
select @@identity - --
Cheers,                   _______________________________________________
 David                   |    David  Elliott    |   Software Engineer
   
|
_________________________| david@elliott.uk.com | PGP Key ID 0x650F4534
|
| No dinner with Mel Gibson?! - Dot Warner
|
-----BEGIN PGP SIGNATURE----- Version: 6.5.8ckt http://www.ipgpp.com/ iQA/AwUBPd0DwfmK8eZlD0U0EQI3fACgsv52o5AvhuroJIVYblYXTnkiDZYAn2Ao y1AeA+bR4KPOwZhZTAa2x7kr =f/lr -----END PGP SIGNATURE----- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.db (#23569) next »