Solved

Record not saved and have got no message

Posted on 2013-10-23
3
304 Views
Last Modified: 2013-10-24
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?
0
Comment
Question by:HuaMinChen
3 Comments
 
LVL 12

Expert Comment

by:Harish Varghese
ID: 39593620
Hello,

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

-Harish
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 39596083
If I remove Try ... catch above, I don't see any error message but the record is not saved as well.
0
 
LVL 33

Accepted Solution

by:
ste5an earned 120 total points
ID: 39596484
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

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now