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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Handling in Stored Procedures

Status
Not open for further replies.

itsmeyogi

Programmer
Sep 18, 2000
6
IN
hi there,

In the application we have developed we have used stored procedures in order to insert, delete and modify.
For tracking the errors like primary key violation, foreign key violation, I am using the @@error variable and checking whether its a zero or not? if it is not zero(unsuccessful) , then an error has occurred, but the error doesnot get trapped ..it doesn't go to that if condition. The sqlserver simply throws an error.How can i handle this? Is there any specific way to handle exceptions in T-SQl like in PL/SQL?

When the stored procedures are called from the VB Front end how do we trap the errors?

And will the Sql Server Handle Concurrent Transactions when stored procedures are used for insert, delete and update statements?

Thanks in Advance
yogitha
 
From VB, the usual ON ERROR code will trap a stored proc that returns a severe error.

If you're concerned about duplicate keys causing a severe error on INSERT, do a SELECT first to see if the key exists.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top