SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


A Simple procedure but no returning value


A Simple procedure but no returning value

Author
Message
Raghunath Garlapati
Raghunath Garlapati
SSC-Enthusiastic
SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)

Group: General Forum Members
Points: 192 Visits: 138
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.
********************************************************/
Jack Corbett
  Jack Corbett
SSC-Forever
SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)

Group: General Forum Members
Points: 43011 Visits: 14925
Duplicate post. Please post any answers here



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming
At best you can say that one job may be more secure than another, but total job security is an illusion. -- Rod at work

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
Raghunath Garlapati
Raghunath Garlapati
SSC-Enthusiastic
SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)

Group: General Forum Members
Points: 192 Visits: 138
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.
********************************************************/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search