In my BEFORE INSERT
trigger, I select data, then I check the value if it's null then I do insert data into table A then else into table B. I select data from a table in another database called ebsms.inbox
then insert to dbsmsra_pit2.smsra_sms
and dbsmsra_pit2.smsra_trash
Here's my complete code :
DROP TRIGGER IF EXIST dbsmsra_pit2.smsra_sms.filterNoHP;
DELIMITER $$
CREATE TRIGGER `filterNoHP`
BEFORE INSERT ON smsra_sms FOR EACH ROW
BEGIN
DECLARE IDx int(11);
DECLARE NumberHP varchar(20);
DECLARE WaktuKirim timestamp;
DECLARE IsiSMS text;
SELECT ID, SenderNumber, ReceivingDateTime,
TextDecoded into IDx, NumberHP, WaktuKirim, IsiSMS FROM ebsms.inbox
WHERE NumberHP in (SELECT NoHP FROM smsra_blokir_number)
and DATE(ReceivingDateTime) = curdate();
IF NumberHP = null then
insert into smsra_sms
set idsms = IDx, SendingDateTime = WaktuKirim,
isi = IsiSMS, pengirim = NumberHP
ON duplicate key update idsms = idsms + IDx;
ELSE
insert into smsra_trash
set Nohp = NumberHP
ON duplicate key update Nohp = Nohp + NumberHP;
END IF;
END$$
DELIMITER ;
here's the error message :
Error Code: 1235. This version of MySQL doesn't yet support
'multiple triggers with the same action time and event for one table'
Please I need help.
NumberHP = null
will be never true as nothing is equal to NULLBEFORE INSERT ON smsra_sms
. So it fires when anINSERT INTO smsra_sms
statement is run. Then why does the trigger also insert intosmsra_sms
? Also, it appears your trigger doesn't really depend on what is being inserted by the triggering statement – that doesn't make much sense either. Normally I would expect to find references toNEW.whatever
in such triggers.