[thelist] ASP/VBSCRIPT: best way to verify successful record insertion

Michael K. Ahn mike at ahnfire.com
Tue Aug 20 13:00:13 CDT 2002


Yes it does:
After an INSERT, SELECT INTO, or bulk copy statement completes,
@@IDENTITY contains the last identity value generated by the statement.
If the statement did not affect any tables with identity columns,
@@IDENTITY returns NULL. If multiple rows are inserted, generating
multiple identity values, @@IDENTITY returns the last identity value
generated. If the statement fires one or more triggers that perform
inserts that generate identity values, calling @@IDENTITY immediately
after the statement returns the last identity value generated by the
triggers. The @@IDENTITY value does not revert to a previous setting if
the INSERT or SELECT INTO statement or bulk copy fails, or if the
transaction is rolled back.

Otherwise, make a transaction, that rolls back if there is an error on
insert.  Then return an error code.  You will know whether or not it was
successful.

michael


-----Original Message-----
From: Chris W. Parker [mailto:cparker at swatgear.com]
Sent: Tuesday, August 20, 2002 12:12 PM
To: thelist at lists.evolt.org
Subject: RE: [thelist] ASP/VBSCRIPT: best way to verify successful
record insertion

> -----Original Message-----
> From: David.Cantrell at Gunter.AF.mil
> [mailto:David.Cantrell at Gunter.AF.mil]
>
> What DBMS are you using? Access and SQL Server both support
> automatically-generated IDs. Just create a new field in the
> table with an
> auto-number or auto-id and set it as the primary key, and you
> are guaranteed
> that no two records will be "identical" as far as the DBMS is
> concerned,
> even though they may have the exact same information byte-for-byte.

i already do this. it keeps each record unique, but it doesn't tell me
that a record has been successfully inserted.


chris.
--
For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to:
http://lists.evolt.org Workers of the Web, evolt !



More information about the thelist mailing list