在注册时我想要如果剩下一边那么我的左边计数会增加而一边是右边然后我的右边是增量而且两边都被填满然后他们的赞助会增加......我怎么能这样做?
在这里,我想增加我的计数器,但它没有正常工作总是计数器显示我的空... ....请告诉我哪里错了。???
DECLARE @regid int
SET @regid=@@IDENTITY
DECLARE @RegistrationCode varchar(100)
DECLARE registrationcodeCursor CURSOR FOR
SELECT [dbo].[RegistrationCode]
(
'P4U',@fname,@mname,@lname,'000',@regid,'34',@dob
)
OPEN registrationcodeCursor
FETCH FROM registrationcodeCursor INTO @RegistrationCode
CLOSE registrationcodeCursor
DEALLOCATE registrationcodeCursor
UPDATE Registration_Master
SET regCode=@RegistrationCode
WHERE registrationid=@regid
DECLARE @regid1 int
SET @regid1=@@IDENTITY
DECLARE @usernm varchar(50)
DECLARE usernameCursor CURSOR FOR
SELECT [dbo].[fullusername]
(
@fname,' ',@mname,' ',@lname
)
OPEN usernameCursor
FETCH FROM usernameCursor INTO @usernm
CLOSE usernameCursor
DEALLOCATE usernameCursor
UPDATE Registration_Master
SET username=@usernm
WHERE registrationid=@regid1
--Pair Matching
SET @count_mem=0
WHILE(@sponcorid!=NULL)
BEGIN
IF(@regCode !=NULL)
BEGIN
DECLARE @countl int
IF(@side ='LEFT')
BEGIN
UPDATE Registration_Master
SET @count_mem=@count_mem+1
WHERE regCode=@regCode AND side='LEFT' AND count_mem=@count_mem
END
DECLARE @countr int
IF(@side='RIGHT')
BEGIN
UPDATE Registration_Master
SET @count_mem=@count_mem+1
WHERE regCode=@regCode AND side='RIGHT' AND count_mem=@count_mem
END
IF(@countl=@countr)
BEGIN
UPDATE Registration_Master
SET @count_mem=@count_mem+1
WHERE regCode=@regCode
IF(@regCode!=NULL)
BEGIN
UPDATE Registration_Master
SET @count_mem=@count_mem+1
WHERE sponcorid=@sponcorid AND count_mem=@count_mem
END
END
END
END
SELECT registrationid, regCode, fname,mname,lname,username, p_password,question,answer, person_address, gender, sponcorid, dob,productname, payment, sponcorname, side, mobile, bankname, baccno,
bankbranch, PAN, IFSC_code, email_id, member_status, count_mem,smart_pin,createddate, is_activate
FROM Registration_Master
WHERE registrationid=@@IDENTITY