Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. -- ================================================
  2. -- Template generated from Template Explorer using:
  3. -- Create Procedure (New Menu).SQL
  4. --
  5. -- Use the Specify Values for Template Parameters
  6. -- command (Ctrl-Shift-M) to fill in the parameter
  7. -- values below.
  8. --
  9. -- This block of comments will not be included in
  10. -- the definition of the procedure.
  11. -- ================================================
  12. SET ANSI_NULLS ON
  13. GO
  14. SET QUOTED_IDENTIFIER ON
  15. GO
  16. -- =============================================
  17. -- Author: <Author,,Name>
  18. -- Create date: <Create Date,,>
  19. -- Description: <Description,,>
  20. -- =============================================
  21. CREATE PROCEDURE _GenderSwitch
  22. -- Add the parameters for the stored procedure here
  23. @CharID INT
  24. ,@ItemrefID INT
  25. AS
  26. SET NOLOCK,XACT_ABORT ON
  27. BEGIN transaction
  28. begin try
  29. DECLARE @Item INT
  30.  
  31. SELECT TOP 1 @Item = I.refitemid
  32. from SRO_VT_SH.._Items I with (nolock)
  33. JOIN SRO_VT_SH.._Inventory N with (nolock)
  34. on I.ID64=N.ItemID
  35. WHERE N.CharID = @CharID and N.Slot = 13 and N.ItemID > 0
  36. IF @Item is null or @Item = 0 or @Item not in (select RefItemIDA from ItemSwitch with (nolock)) or @Item not in (select refitemidb from ItemSwitch with (nolock))
  37. BEGIN
  38. ROLLBACK TRANSACTION
  39. RETURN 0;
  40. END
  41. DECLARE @NEWITEM INT
  42. SELECT @NEWITEM = case
  43. when @Item in (select refitemida from ItemSwitch with (nolock)) then (select top 1 refitemidb from ItemSwitch WITH (NOLOCK) where ScrollID = @ItemrefID and RefItemIDA = @Item)
  44. else (select top 1 refitemida from ItemSwitch with (nolock) where ScrollID = @ItemrefID and RefItemIDB = @Item)
  45. end
  46.  
  47.  
  48. UPDATE I
  49. SET RefItemID = @NEWITEM
  50. from SRO_VT_SH.._Items i
  51. join sro_vt_sh.._Inventory n
  52. on i.ID64 = n.ItemID
  53. where n.charid = @CharID and n.slot=13
  54. return 1;
  55. END try
  56. begin catch
  57. ERRORHANDLER:
  58. rollback transaction
  59. return -1
  60. end catch
  61. commit transaction
  62. GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement