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?
LVL 11
HuaMin ChenSystem AnalystAsked:
Who is Participating?
 
ste5anSenior DeveloperCommented:
Why do you expect to "see" a message? You're only assigning one to a variable, but never printing it to console or elsewhere.
0
 
Harish VargheseProject LeaderCommented:
Hello,

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

-Harish
0
 
HuaMin ChenSystem AnalystAuthor Commented:
If I remove Try ... catch above, I don't see any error message but the record is not saved as well.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.