搜索
 找回密码
 加入

新的LOGIN存储,谁能看出有无错误

ctgwglzc 2008-11-5 18:05:35 1072
  1. CREATE PROCEDURE ACCOUNT_LOGIN
  2. @AccountID    varchar(21),
  3. @Password    varchar(13),
  4. @nRet        smallint    OUTPUT

  5. AS
  6. declare @ban  int , @ban1 int, @ban2 int
  7. select @nRet = count(straccountid) from currentuser
  8. select @ban = authority from userdata where struserid = (select strcharid1 from account_char where straccountid = @AccountID and strcharid1 is not null )
  9. select @ban1 = authority from userdata where struserid = (select strcharid2 from account_char where straccountid = @AccountID and strcharid1 is not null )
  10. select @ban2 = authority from userdata where struserid = (select strcharid3 from account_char where straccountid = @AccountID and strcharid1 is not null )

  11. if @ban = 255 or @ban1 = 255 or @ban2 = 255
  12. begin
  13. Set @nRet = 4
  14.         RETURN
  15. end
  16. declare @gankss varchar(21)
  17. select @nRet = count(straccountid) from currentuser
  18. select @gankss = count(strAccountID) from premium_service where strAccountID = @AccountID
  19. if @gankss =  0 and @nRet>100
  20. begin
  21. Set @nRet = 0
  22. end

  23. DELETE FROM CURRENTUSER WHERE strAccountID = @AccountID

  24. exec rundupecheckinn @AccountID

  25. DECLARE @Nation tinyint, @CharNum smallint
  26. SET @Nation = 0
  27. SET @CharNum = 0

  28. DECLARE @pwd varchar(13)

  29. SET @pwd = null

  30. SELECT @pwd = strPasswd FROM [dbo].[TB_USER] WHERE strAccountID = @AccountID and idays=6
  31. IF @pwd IS null
  32. BEGIN
  33.     SET @nRet = 0
  34.              --SET @nRet = 4
  35.     RETURN
  36. END

  37. ELSE IF @pwd <> @Password
  38. BEGIN
  39.     SET @nRet = 0
  40.              --SET @nRet = 3
  41.     RETURN
  42. END

  43. DECLARE @gokhantasci varchar(21)
  44. select @gokhantasci = count(straccountid)  FROM premium_service WHERE strAccountID = @AccountID

  45. if @gokhantasci = 0
  46. begin
  47. insert into PREMIUM_SERVICE (strAccountID, strType, nDays) VALUES (@AccountID, 1, 3)
  48. end

  49. SELECT @Nation = bNation, @CharNum = bCharNum FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID
  50. IF @@ROWCOUNT = 0
  51. BEGIN
  52.     SET @nRet = 1
  53.     RETURN
  54. END
  55. IF @CharNum = 0
  56. BEGIN
  57.     SET @nRet = 1
  58.     RETURN
  59. END
  60. ELSE
  61. BEGIN
  62.     SET @nRet = @Nation+1
  63.              --SET @nRet = 1
  64.     RETURN
  65. END
  66. GO
  67. SET QUOTED_IDENTIFIER OFF
  68. GO
  69. SET ANSI_NULLS ON
  70. GO
复制代码

6 回复

binwang
2008-11-5 09:59:47
点击查看详情
逻辑还是语法错误?
feike
2008-11-5 11:22:11
跟帖做个简要解释,有问号的地方具有不确定性。有不对的请指正,我没弄明白也请高手们指教。

CREATE PROCEDURE ACCOUNT_LOGIN
@AccountID varchar(21), ;接收账户信息
@Password varchar(13),  ;接收密码信息
@nRet smallint OUTPUT   ;设置为输出

AS
declare @ban int , @ban1 int, @ban2 int;定义ban ban1 ban2
select @nRet = count(straccountid) from currentuser;在currentuser表内查询有否输入的账户名
select @ban = authority from userdata where struserid = (select strcharid1 from account_char where straccountid = @AccountID and strcharid1 is not null );在userdata表内查询账户的ban信息
select @ban1 = authority from userdata where struserid = (select strcharid2 from account_char where straccountid = @AccountID and strcharid1 is not null );在userdata表内查询账户的ban1信息
select @ban2 = authority from userdata where struserid = (select strcharid3 from account_char where straccountid = @AccountID and strcharid1 is not null );在userdata表内查询账户的ban2信息

if @ban = 255 or @ban1 = 255 or @ban2 = 255;如果ban是被停权账户则设置nRet=4(不给登陆或显示账户停权信息)
begin
Set @nRet = 4
RETURN
end

declare @gankss varchar(21) ;定义变量gankss
select @nRet = count(straccountid) from currentuser;在currentuser表内查询账户信息
select @gankss = count(strAccountID) from premium_service where strAccountID = @AccountID;在premium_service表内查询账户信息
if @gankss = 0 and @nRet>100;如果表premium_service无此账户信息以及表currentuser内的账户信息>100则允许进入?
begin
Set @nRet = 0
end

DELETE FROM CURRENTUSER WHERE strAccountID = @AccountID;删除currentuser表内的账户信息

exec rundupecheckinn @AccountID;执行??

DECLARE @Nation tinyint, @CharNum smallint;定义变量
SET @Nation = 0 ;设置为0
SET @CharNum = 0;设置为0

DECLARE @pwd varchar(13);定义密码字段长度为13

SET @pwd = null;设定密码默认值为空

SELECT @pwd = strPasswd FROM [dbo].[TB_USER] WHERE strAccountID = @AccountID and idays=6;查询比较密码
IF @pwd IS null;如果查询无结果,返回密码错误信息
BEGIN
SET @nRet = 0
--SET @nRet = 4
RETURN
END

ELSE IF @pwd <> @Password;如果密码不相符,返回密码错误信息
BEGIN
SET @nRet = 0
--SET @nRet = 3
RETURN
END

DECLARE @gokhantasci varchar(21);定义
select @gokhantasci = count(straccountid) FROM premium_service WHERE strAccountID = @AccountID;在premium_service表内查询账户信息

if @gokhantasci = 0;如果表内无此账户信息则插入该账户信息
begin
insert into PREMIUM_SERVICE (strAccountID, strType, nDays) VALUES (@AccountID, 1, 3)
end

SELECT @Nation = bNation, @CharNum = bCharNum FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID;在ACCOUNT_CHAR表内查询国家类别

;下面这些没弄明白,但我知道是与国家(种族)的选择有关
IF @@ROWCOUNT = 0;
BEGIN
SET @nRet = 1
RETURN
END
IF @CharNum = 0;
BEGIN
SET @nRet = 1
RETURN
END
ELSE
BEGIN
SET @nRet = @Nation+1
--SET @nRet = 1
RETURN
END
GO
SET QUOTED_IDENTIFIER OFF ;关闭??
GO
SET ANSI_NULLS ON ;设置??
GO
yl941
2008-11-5 11:43:54
本身没错误,这里需要强制排序就可以了!
declare @ban int , @ban1 int, @ban2 int
select @nRet = count(straccountid) from currentuser
select @ban = authority from userdata where struserid = (select strcharid1 from account_char where straccountid = @AccountID and strcharid1 is not null )
select @ban1 = authority from userdata where struserid = (select strcharid2 from account_char where straccountid = @AccountID and strcharid1 is not null )
select @ban2 = authority from userdata where struserid = (select strcharid3 from account_char where straccountid = @AccountID and strcharid1 is not null )
yl941
2008-11-5 11:50:15
改成如下即可正常使用
declare @ban int , @ban1 int, @ban2 int
select @nRet = count(straccountid) from currentuser
select @ban = authority from userdata where struserid collate database_default= (select strcharid1 from account_char where straccountid collate database_default= @AccountID and strcharid1 is not null )
select @ban1 = authority from userdata where struserid collate database_default= (select strcharid2 from account_char where straccountid collate database_default= @AccountID and strcharid1 is not null )
select @ban2 = authority from userdata where struserid collate database_default= (select strcharid3 from account_char where straccountid collate database_default= @AccountID and strcharid1 is not null )
rainbody
2008-11-5 16:21:27
学习的帖子要顶
ymhuang
2008-11-5 18:05:35
要这么多ban来干什么呢?tb_user里面不是有一列是authority吗?
高级模式
游客