Sql Server 2000 and Transactions - Must be male as it won't commit.
I have been using Sql Server for God knows how long and have this problem with transactions which has got me miffed !
Nothing extradordinary in my Sql.
I have a SP which contains various Insert & Update commands within a Transaction block and I am checking for errors after every statement. I know the Insert/Update code runs ok as when I take the transaction commands out it runs ok. When using the transaction block all the code executes and then it hangs and hangs and hangs waiting to be commited. Why does it not commit the transactions? Am I so hanged up on the transactions that I am missing an obvious error with the code flow ?
The code is , generically as follows :
I have been using Sql Server for God knows how long and have this problem with transactions which has got me miffed !
Nothing extradordinary in my Sql.
I have a SP which contains various Insert & Update commands within a Transaction block and I am checking for errors after every statement. I know the Insert/Update code runs ok as when I take the transaction commands out it runs ok. When using the transaction block all the code executes and then it hangs and hangs and hangs waiting to be commited. Why does it not commit the transactions? Am I so hanged up on the transactions that I am missing an obvious error with the code flow ?
The code is , generically as follows :
Code:
alter proc uspTEST as
declare @rc int, @LE_ErrCode int, @LE_ErrMsg nvarchar(4000)
[red][b]begin tran A[/b][/red]
=========================================================
insert into ........
select ......from....
Set @rc = @@error
If @rc <> 0
Begin
set @LE_ErrCode = @rc
set @LE_ErrMsg = '...error message....'
goto Err
End
======================================================
Update ...
where ...
Set @rc = @@error
If @rc <> 0
Begin
set @LE_ErrCode = @rc
set @LE_ErrMsg = '...Error message...'
goto Err
End
.
. More /InsertUpdate statements
.
Set @rc = @@error
If @rc <> 0
Begin
set @LE_ErrCode = @rc
set @LE_ErrMsg = '...Error message...' goto Err
End
[red][b]commit tran [/b][/red]
return @rc
Err:
[red][b]if @@trancount > 0 rollback tran[/b][/red]
exec uspErrorProc
return @rc