in reply to Perl ODBC question
Actually, this is an SQL issue and not a Perl-specific one.
If you want to find the last identity after an insert and you are using MS SQL Server, you can use @@IDENTITY:
SELECT @@IDENTITY
Unfortunately, this is not a terribly robust solution. This will return the last identity created from the current connection. However, you must run this immediately after your insert as subsequent inserts will overwrite this value. Further, if you have triggers in your database that fire when you do your insert and if these triggers do inserts, then @@IDENTITY will likely not return the data you are expecting (of course, I have serious reservations about triggers themselves). If you are using MS SQL Server 2000, this problem has been solved.
If you run the select immediately after your insert and you do not have any triggers, you should have no problem.
Cheers,
Ovid
Vote for paco!
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
@@identity (boo)
by boo_radley (Parson) on Sep 14, 2001 at 01:36 UTC | |
|
Re: (Ovid) Re: Perl ODBC question
by mpeppler (Vicar) on Oct 09, 2001 at 01:23 UTC |