Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Confused over return value

Author  Topic 

denis_the_thief
Aged Yak Warrior

596 Posts

Posted - 2013-04-03 : 16:03:30

I was looking at this stored proc and was confused over this code. Here is a snippet:


alter PROCEDURE [xxx]
@Lang tinyint = 0
,@CurrUserID varchar(10) = null
AS

BEGIN
DECLARE @errnum int

... //I removed several lines



exec @errnum = _OrganizationDocketRate_Fetch @Lang, @CurrUserID
END
RETURN @@ERROR
GO



What I think is that there is no point to @errnum. Is this true? i.e. I don't see how it can be returned.

ScottPletcher
Aged Yak Warrior

550 Posts

Posted - 2013-04-03 : 16:11:12
Quite right; in that code, @errnum is not used, but it will still contain the value RETURNed by the _OrganizationDocketRate_Fetch procedure.
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-04-03 : 16:13:59
Instead of "RETURN @@ERROR", you can use "RETURN @@errnum", if that is indeed what you want to do. But, as written, the value of @errnum is assigned but not used, so there is no point to having it.
Go to Top of Page

denis_the_thief
Aged Yak Warrior

596 Posts

Posted - 2013-04-03 : 16:34:52
Thanks
Go to Top of Page
   

- Advertisement -