Read 183 times | Created 2013-06-30 15:09:23 | Updated 2013-06-30 15:20:43 | | |

 

DELIMITER |
CREATE EVENT notif_jatuh_tempo
ON SCHEDULE
  EVERY 1 DAY
DO
BEGIN      
  INSERT INTO 
    outbox (
      InsertIntoDB,
      SendingDateTime,
      DestinationNumber,
      TextDecoded,
      SendingTimeOut,
      DeliveryReport,
      CreatorID
    )
  SELECT 
    SYSDATE(),
    SYSDATE,
    n.hp,
    'tanggal jatuh tempo pinjaman anda tinggal 2 hari lagi',
    SYSDATE(),
    'yes',
    'system'
  FROM 
    pinjaman p
    LEFT JOIN nasabah n USING(no_nasabah)
  WHERE 
    DATE_SUB(DATE_ADD(p.tanggal_pinjam,INTERVAL 1 MONTH), INTERVAL 2 DAY)=CURRENT_DATE;
END |
DELIMITER ;