Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Record not saved and have got no message

Posted on 2013-10-23
3
Medium Priority
?
323 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 11

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 36

Accepted Solution

by:
ste5an earned 480 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

877 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