Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

A Simple procedure but no returning value Expand / Collapse
Author
Message
Posted Thursday, April 2, 2009 6:42 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, June 28, 2013 5:28 AM
Points: 42, Visits: 137
I have a procedure which shuld return an int depending on Insertion done but it is not returning any thing though i have written Return statement also

Here is my Procedure

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[UserRoleMapping]
@userProgrammeId int,@roleProgrammeId int,@createdBy int,@createdDate datetime,@loggedInAs int
as
begin

declare @out int
declare @return int
set nocount on
begin try
begin tran UserRoleMapping

Insert Into User_Roles(Fk_users,Fk_Roles,CreatedBy,CreatedDate,LoggedInAs)
values(@userProgrammeId,@roleProgrammeId,@createdBy,@createdDate,@loggedInAs)
commit tran UserRoleMapping
set @return=1
end try
begin catch
IF (XACT_STATE()) = -1
BEGIN
ROLLBACK TRAN UserRoleMapping
set @return=0
END
ELSE IF (XACT_STATE()) = 1
BEGIN
--it now depends on the type of error or possibly the line number
--of the error
IF ERROR_NUMBER() = 547
BEGIN
ROLLBACK TRAN UserRoleMapping
set @return=0

END
ELSE IF ERROR_NUMBER() = 2627
BEGIN
ROLLBACK TRAN UserRoleMapping
set @return=0
END
END
END CATCH

return @return
set nocount off
end




Can any one please tell me y it is not returning value as it is very urgent to me


/********************************************************
Technology is just a tool,in terms of getting the kids working together and motivating them,the teacher is the most important.
********************************************************/
Post #688794
Posted Thursday, April 2, 2009 6:54 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 6:26 AM
Points: 10,381, Visits: 13,435
Duplicate post. Please post any answers here



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #688813
Posted Thursday, April 2, 2009 6:58 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, June 28, 2013 5:28 AM
Points: 42, Visits: 137
Sorry for 2 Posts first time site gave me some error so i entered it again, but it took both the 2 posts

/********************************************************
Technology is just a tool,in terms of getting the kids working together and motivating them,the teacher is the most important.
********************************************************/
Post #688818
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse