/*check whether a member is downline or not
jerome 5_9_09
if a member is downline it return 1 other wise 0
*/
ALTER function [dbo].[IsSponsor](@MemberID int,@UserID int)RETURNS int
as begin
declare @status int,@TempID int
set @status=0
set @TempID=@UserID
if @MemberID=@UserID
set @status=1
else
begin
while @TempID>0
begin
select @TempID=isnull(min(userid),0) from login where username=(select sponsorid from registration where loginid=@UserID)
set @UserID=@TempID
if @TempID=@MemberID
begin
set @status= 1
break
end
end
end
return @status
end
/*
call a function***********
select dbo.IsSponsor(1,1)
print dbo.IsSponsor(1,21)
*/
Thursday, October 8, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment