Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DELIMITER $
- CREATE trigger otomatis after INSERT on inbox
- FOR EACH ROW BEGIN
- DECLARE pilihan VARCHAR(3);
- DECLARE no_pengirim VARCHAR(200);
- SET pilihan=NEW.TextDecoded;
- SET no_pengirim=NEW.SenderNumber;
- IF (SELECT COUNT(*)
- FROM inbox
- WHERE SenderNumber=no_pengirim
- AND TextDecoded=pilihan) > 1 THEN
- INSERT INTO outbox (DestinationNumber,TextDecoded)
- VALUES (no_pengirim , 'Anda sudah pernah Memilih');
- ELSEIF (SELECT COUNT(*)
- FROM inbox
- WHERE SenderNumber=no_pengirim
- AND TextDecoded=pilihan) = 0 THEN
- BEGIN
- UPDATE poll
- SET jumlah = jumlah + 1
- WHERE kode=pilihan;
- INSERT INTO outbox (DestinationNumber,TextDecoded)
- VALUES (no_pengirim , 'Terima Kasih Pilihan Anda Sudah Tersimpan');
- END;
- ELSEIF (SELECT COUNT(*)
- FROM poll
- WHERE kode=pilihan) = 0 THEN
- INSERT INTO outbox (DestinationNumber,TextDecoded)
- VALUES (no_pengirim , 'Pilihan anda tidak ada dalam list');
- END IF;
- END $
- DELIMITER ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement