Advertisement
cdsatrian

polling update r2

Jun 30th, 2012
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.81 KB | None | 0 0
  1. delimiter $
  2. create trigger otomatis after insert on inbox
  3. for each row begin
  4. if (select count(*) from inbox where SenderNumber=new.SenderNumber and TextDecoded=new.TextDecoded) > 1 then
  5. insert into outbox (DestinationNumber,TextDecoded) values (new.SenderNumber , 'Anda sudah pernah Memilih');
  6. elseif (select count(*) from inbox where SenderNumber=new.SenderNumber and TextDecoded=new.TextDecoded) = 1 then
  7. begin
  8. update poll set Jumlah = Jumlah + 1 where Kode=new.TextDecoded;
  9. insert into outbox (DestinationNumber,TextDecoded) values (new.SenderNumber , 'Terima Kasih Pilihan Anda Sudah Tersimpan');
  10. end;
  11. elseif (select count(*) from poll where Kode=new.TextDecoded) = 0 then
  12. insert into outbox (DestinationNumber,TextDecoded) values (new.SenderNumber , 'Pilihan anda tidak ada dalam list');
  13. end if;
  14. end $
  15. delimiter ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement