Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

@@Error

Status
Not open for further replies.

Josephus

Programmer
Joined
May 1, 2003
Messages
1
Location
US

INSERT INTO [Case] (FileYear, FileNbr)
VALUES (@FileYear, @FileNbr)


IF @@ERROR = 0
BEGIN
SET @ReturnCode = 0
END
ELSE
BEGIN
SET @ReturnCode = -1
END

return
-------

I have written this in a stored procedure. If the FileYear and FileNbr are duplicates and already exist in the database I want to set @ReturnCode = -1. If they do not exist I want to set it to 0. I run this stored procedure from an ASP page. When the procedure finds it to be duplicates the system automatically aborts the procedure and sends a duplicate record message to the screen and the "IF @Error = 0" statement never gets executed. Why can't I get the rest of the procedure to execute and how can I over come this?
 
Do a SELECT first. If @@RowCount > 0 then return, otherwise do the INSERT.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top