USE [ini3_py_account]
GO
/****** Object: StoredProcedure [dbo].[SP_PANGYA_REGIST] Script Date: 02/05/2011 20:02:14 ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
ALTER PROCEDURE [dbo].[SP_PANGYA_REGIST]
@idcard CHAR(13),
@sex BIT,
@birthday VARCHAR(50),
@zipcode CHAR(5),
@id VARCHAR(32),
@pswd VARCHAR(32)
AS
IF NOT EXISTS( SELECT UserID FROM Ini3_UserLogin WHERE UserID = @id AND VisaIDCard = @idcard)
BEGIN
INSERT INTO Ini3_UserLogin(UserID, Password, Birthday, Sex, VisaIDCard, Confirm18, UserName, ZipCode)
VALUES (@id, @pswd, CONVERT(DATETIME,@birthday), @sex, @idcard, '0', @id, @zipcode)
-- Registration Done, adding cookies procedure below
DECLARE @UserName varchar(32)
DECLARE @UserIdx int
-- Static sitecode, is always 'ini3'
DECLARE @siteCode varchar(5)
SET @siteCode = N'ini3'
-- Get the nickname and the idx for the specified user from the game-server database...
SELECT @UserName = [UserID], @UserIdx = [idx] FROM [ini3_py_account].[dbo].[Ini3_UserLogin]
WHERE userid = @id;
-- Check whether we have previous records for this user...
SELECT UserNo, UserID FROM [INI3BILL_DB].[dbo].TAccountMst
WHERE UserNo = @UserIdx
AND UserID = @id
IF @@ROWCOUNT = 0
-- User never got cookies so we need to create a new row for him...
INSERT INTO [INI3BILL_DB].[dbo].TAccountMst ([SiteCode], [UserNo], [UserID], [UserName], [CookieAmt])
VALUES ( @siteCode, @UserIdx, @id, @UserName, '250000')
ELSE
-- User has cookies so we can simply update the old value
UPDATE [INI3BILL_DB].[dbo].TAccountMst SET [CookieAmt] = [CookieAmt] + '250000', [UpdDate] = CURRENT_TIMESTAMP
WHERE [UserNo] = @UserIdx AND [UserID] = @id
END