Solved

Record not saved and have got no message

Posted on 2013-10-23
3
309 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

685 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