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

Transactions in SQL 7.0

Status
Not open for further replies.

Tarzan613

Programmer
Jun 10, 2002
10
0
0
US
I have a store procedure and this store procedure must be robust enough to handle a fault in the middle of processing, which would cause it to terminate before completing.
This means that it either needs to be self restarting, or able to be restarted in such a way that it doesn't "double count" any data.
 
create procedure testSP (@varIn int)
as
begin tran
declare @a int
select @a = count(*) from table1
where field1 = @varIn
if @@error > 0 goto ErrorHandler
if @a = 0 begin
raiserror('Doesn''t exist', 16, 1)
goto ErrorHandler
end
insert table2 (t2field1)
select field1 from table1
where field1 = @varIn
if @@error > 0 goto ErrorHandler
commit tran
return 0
ErrorHandler:
rollback tran
return @@error codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
<insert witticism here>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top