Link to home
Start Free TrialLog in
Avatar of Peter Chan
Peter ChanFlag for Hong Kong

asked on

Record not saved and have got no message

Sorry, I change it to be
Hi,
I have the codes within my SP like
	...
	begin try
		insert into ...
	end try
	begin catch
		select @ErrorMessage=ERROR_MESSAGE();
		
		if @@TRANCOUNT>0
		begin
			rollback tran
			set @message='...'
			return
		end
	end catch
	if @@TRANCOUNT>0
	begin
		commit tran
		set @message='...'
	end
	...

Open in new window

but I do get no message returned and no record has been saved, while I did see @@TRANCOUNT is having the value of 2, right before the last "if" part. why?
Avatar of Harish Varghese
Harish Varghese
Flag of India image

Hello,

What is the error message that you are expecting? Try removing the TRY.. CATCH and see what error is thrown.

-Harish
Avatar of Peter Chan

ASKER

If I remove Try ... catch above, I don't see any error message but the record is not saved as well.
ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial