mercredi 27 mai 2015

Trigger - If statement SQL

I'm trying to use a 'trigger' with IF statement. However when I move my mouse over "IF" a error shows; "Incorrect syntax near "IF". Expecting EXTERNAL"

   DROP TRIGGER JobSuits
   ON ALL SERVER;
   CREATE TRIGGER JobSuits ON SRO_VT_LOG.._LogEventItem
   FOR INSERT, DELETE
   AS
   IF (@Operation = 41)
   BEGIN
   declare @ItemID int;
   SELECT @ItemID = I.itemID
   FROM SRO_VT_SH.._Inventory I
   JOIN SRO_VT_SH.._Items IT
   ON I.ItemID = IT.ID64
   WHERE I.CharID = @CharID
   AND I.Slot = 8

   IF @ItemID < 0
   BEGIN
   INSERT INTO SRO_VT_SH.._TimedJob
 SELECT @CharID, 0,(CASE 
     WHEN @ItemrefID = 47060 OR @ItemRefID = 47065 THEN '33826' 
     WHEN @ItemrefID = 47061 OR @ItemRefID = 47066 THEN '33827' 
     WHEN @ItemrefID = 47062 OR @ItemRefID = 47067 THEN '33828' 
     WHEN @ItemrefID = 47063 OR @ItemRefID = 47068 THEN '33829' 
     WHEN @ItemrefID = 47064 OR @ItemRefID = 47069 THEN '33830' 
     END), 1209592, 0, 0, 0, 0, 0, 0, 0, 0, 100000003461319, 0
     END
     ELSE IF @ItemID > 0
      DELETE FROM SRO_VT_SH.._TimedJob
      WHERE  CharID = @CharID
      AND   JobID IN (33816,33817,33818,33819,33820,33821,33822,33823,33824,33825,33826,33827,33828,33829,33830)
     END

It would be great if you could help.. thank you!

Aucun commentaire:

Enregistrer un commentaire