0
我有這個:SQL觸發器不執行...做錯了什麼?
這是在chars_insert之前。
BEGIN
IF EXISTS (SELECT * FROM chars WHERE accid = NEW.accid)
BEGIN
INSERT INTO `char_vars` SET `charid = NEW.charid, `varname` = `NotFirstChar`, `value` = 1;
END
INSERT INTO `char_equip` SET `charid` = NEW.charid;
INSERT INTO `char_exp` SET `charid` = NEW.charid;
INSERT INTO `char_jobs` SET `charid` = NEW.charid;
INSERT INTO `char_pet` SET `charid` = NEW.charid;
INSERT INTO `char_points` SET `charid` = NEW.charid;
INSERT INTO `char_profile` SET `charid` = NEW.charid;
INSERT INTO `char_storage` SET `charid` = NEW.charid;
INSERT INTO `char_inventory` SET `charid` = NEW.charid;
END
我剛剛添加了IF EXISTS部分......這打破了觸發器。我試圖找出一個被認可的人是否已經擁有一個角色,如果他們這麼做了,就向該角色添加一個變量,說這不是他們的第一個角色。它說錯誤在IF EXISTS行,但我看不出錯誤...請幫忙嗎?
語法對於觸發器和過程往往是特定於實現的。請標記您正在使用的SQL的方言。 – Turophile
@Turophile SQL server 2012,MySQL,並在Navicat中使用 –