Guest User

Untitled

a guest
Jul 16th, 2018
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. CREATE PROCEDURE dbo.ACCOUNT_LOGIN
  2. @AccountID varchar(21),
  3. @Password varchar(32),
  4. @nRet smallint OUTPUT
  5. AS
  6. /*
  7. Author: Nero
  8. */
  9. DECLARE @AccountID2 varchar(50), @Password2 varchar(50), @Authority smallint, @Nation tinyint, @CharNum tinyint
  10. SET @Nation = 0
  11. SET @CharNum = 0
  12. -- Otomatik üyelik
  13. SELECT @AccountID2 = COUNT(strAccountID) FROM TB_USER WHERE strAccountID = @AccountID
  14. IF @AccountID2 = 0
  15. BEGIN
  16. INSERT INTO TB_USER (strAccountID, strPasswd) VALUES (@AccountID, @Password)
  17. END
  18. /* Normal üyelik
  19. SELECT @AccountID2 = COUNT(strAccountID) FROM TB_USER WHERE strAccountID = @AccountID
  20. IF @AccountID2 = 0
  21. BEGIN
  22. SET @nRet = 2 -- Account doesnt exist.
  23. RETURN
  24. END
  25. */
  26. SELECT @Password2 = strPasswd, @Authority = strAuthority FROM TB_USER WHERE strAccountID = @AccountID
  27. IF @Password2 IS null or @Password2 != @Password
  28. BEGIN
  29. SET @nRet = 3 -- Invalid password.
  30. RETURN
  31. END
  32. ELSE
  33. IF @Authority = 255
  34. BEGIN
  35. SET @nRet = 4 -- Account is banned.
  36. RETURN
  37. END
  38. ELSE
  39. BEGIN
  40. DELETE CURRENTUSER WHERE strAccountID = @AccountID
  41. SET @nRet = @Nation+1
  42. RETURN
  43. END
  44.  
  45. SELECT @Nation = bNation, @CharNum = bCharNum FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID
  46. IF @@ROWCOUNT = 0
  47. BEGIN
  48. SET @nRet = @Nation+1
  49. RETURN
  50. END
  51. IF @CharNum = 0
  52. BEGIN
  53. SET @nRet = @Nation+1
  54. RETURN
  55. END
  56. ELSE
  57. BEGIN
  58. SET @nRet = @Nation+1
  59. RETURN
  60. END
  61. GO
Add Comment
Please, Sign In to add comment