in reply to Re: mssql query
in thread mssql query
What will NOT work is selecting the @@identity value IF the insert happened in a stored procedure, because the @@identity variable is localized. So the following:$dbh->do("insert ... "); $sth = $dbh->prepare('select @@identity'); $sth->execute(); my $data = $sth->fetch;...
will NOT return the @@identity value generated in the stored procedure. This is the reason why you can't get the @@identity value after doing an insert with placeholders (at least with Sybase): any statement with placeholders generates a temporary stored procedure, hence localizing the @@identity variable.$dbh->do("exec some_proc_with_an_insert 1,2,3"); $sth = $dbh->prepare('select @@identity'); $sth->execute(); my $data = $sth->fetch;
Michael
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: mssql query
by demerphq (Chancellor) on Dec 02, 2003 at 00:08 UTC |