mysql - SQL trigger not executing...doing something wrong? -
i have this:
this on chars_insert, before.
begin if exists (select * chars accid = new.accid) begin insert `char_vars` set `charid = new.charid, `varname` = `notfirstchar`, `value` = 1; end insert `char_equip` set `charid` = new.charid; insert `char_exp` set `charid` = new.charid; insert `char_jobs` set `charid` = new.charid; insert `char_pet` set `charid` = new.charid; insert `char_points` set `charid` = new.charid; insert `char_profile` set `charid` = new.charid; insert `char_storage` set `charid` = new.charid; insert `char_inventory` set `charid` = new.charid; end
i had added if exists part...which broke trigger. trying find if 1 accountid has character , if do, add variable created character saying not first one. says error on if exists line, see no error...help please?
try changing code in following way mysql:
begin if exists (select * chars accid = new.accid) insert `char_vars` set `charid` = new.charid, `varname` = `notfirstchar`, `value` = 1; end if; insert `char_equip` set `charid` = new.charid; insert `char_exp` set `charid` = new.charid; insert `char_jobs` set `charid` = new.charid; insert `char_pet` set `charid` = new.charid; insert `char_points` set `charid` = new.charid; insert `char_profile` set `charid` = new.charid; insert `char_storage` set `charid` = new.charid; insert `char_inventory` set `charid` = new.charid; end
also if notfirstchars
meant constant string (not field name) should change quotes: 'notfirstchars'
Comments
Post a Comment