1

在注册时,我想如果左边是左边,那么我的左边计数会增加,右边是右边,然后我的右边是增加,两边都被填满,然后他们的赞助商会增加......我该怎么做????

在这里我想增加我的计数器,但它不能正常工作总是计数器显示我为空....,请告诉我哪里错了。???

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
4

0 回答 0