Groups | Blog | Home
all groups > sql server programming > april 2004 >

sql server programming : Detect Update done with table have timestamp.


A.Fish
4/22/2004 11:01:06 PM
Hi
I had a table with column of timestamp to do concurrency control. The Update storedprocedure is as follow. How should I detect if error happen on updating? I got @@Error = 0 and @@Rowcount =1 everytime even update fail. Please help

UPDATE Customers SET CustomerID = @CustomerID, CompanyName = @CompanyName
ContactName = @ContactName, ContactTitle = @ContactTitle, City = @Cit
WHERE (CustomerID = @Original_CustomerID) AND
(TimeStamp = @Original_TimeStamp

Best regards
Fish

A.Fish
4/23/2004 2:16:01 AM
Hi
I found the problem. My error handling like following
SET @Error = @@Error
SET @RowCnt = @@Rowcoun
IF (@RowCnt = 0
..
EN

The correct one
SELECT @Error = @@Error, @RowCnt = @@Rowcoun
IF (@RowCnt = 0
..
EN

Thanks for your attention
Fish
Tibor Karaszi
4/23/2004 8:53:17 AM
Can you post the error trapping code as well?

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp


[quoted text, click to view]
How should I detect if error happen on updating? I got @@Error = 0 and @@Rowcount =1 everytime even update
fail. Please help.
[quoted text, click to view]

AddThis Social Bookmark Button