Articles Comments

{ Berbagi, Menulis, Dan Mengajar } Ilmu… » 7. Operating System » Trigger –> Change 081 –> +6281

Trigger –> Change 081 –> +6281

DOWNLOAD SOURCE –>> CobaTrigger1

DELIMITER $$

USE `coba`$$

DROP TRIGGER `TriggerCopy`$$

CREATE

TRIGGER `TriggerCopy` AFTER INSERT ON `tabel1`
FOR EACH ROW BEGIN
DECLARE NoTelp TEXT;

INSERT INTO coba.tabel2 (id,Nama,Alamat)
VALUE ( NEW.Id,NEW.Nama,NEW.Alamat);

IF (SELECT LEFT(NEW.Nama,3))=081 THEN

UPDATE tabel2
SET nama = REPLACE(nama,’081′,’+6281′);

ELSEIF (SELECT LEFT(NEW.Nama,3))=085 THEN

UPDATE tabel2
SET nama = REPLACE(nama,’085′,’+6285′);

END IF;

END$$

DELIMITER ;

Filed under: 7. Operating System

Leave a Reply

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>