Re: MSSQL and @@identity

From: Date: Wed, 11 Apr 2001 11:00:52 +0000
Subject: Re: MSSQL and @@identity
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-8477@lists.php.net to get a copy of this message
On 11 Apr 2001, at 11:40, Daniel Fairs wrote: > Hi, > > I'm trying to insert a row into an MSSQL7 table using the SQL string: > > INSERT INTO person (birthdate,deathdate,sname,othername,motherid,fatherid) > VALUES ('1978-10-06',NULL,'Fairs','Daniel',NULL,NULL) SELECT > @@identity AS > last_identity > > The actual PHP code is > $oRes = mssql_query("SET NOCOUNT ON " . $sSQL, $this->iConnIndex) ; > if ($oRes) echo "yea" ; else echo "nay" ; die() ; > > ... and 'nay' gets printed.... > > I've tried both SET NOCOUNT ON and SET NOCOUNT OFF, and also omitting the > SET NOCOUNT completely. Any ideas why I'm not getting the last id back? > Maybe the problem is simpler: on some version of mssql API (maybe all?), I've verified that mssql_returns non-zero only for SELECT statements (returns the number of rows selected, to be more precise). All other statements return zero, so you could see that darn "nay" even if the query worked perfectly :-(... HTH, bye! /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ Fabrizio Ermini Alternate E-mail: C.so Umberto, 7 faermini@tin.it loc. Meleto Valdarno Mail on GSM: (keep it short!) 52020 Cavriglia (AR) faermini@sms.tin.it

« previous php.db (#8477) next »