/*****************************************************************************
*
* Filename         - $Workfile:   carrier_site_config_triggers.sql  $
*
*                     Name              Date      Version     CR Number
* Author           - See revision history below.
* Last Update      - See revision history below.
*
* Project Name     - TAGTRAK(Oracle Database)
*
* Source Code
* Identifier       - 0/3/300/8010/112
*
* Design Spec
* Section          -
*
* Contents         -  Live Schema: triggers for carrier_site_config table
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 2006
*
*****************************************************************************/
CREATE OR REPLACE TRIGGER td_carrier_site_config
BEFORE DELETE ON carrier_site_config
FOR EACH ROW

BEGIN

  -- Is this a SEND_BMM item?
  IF (:OLD.config_item = 'SEND_BMM') THEN

    -- Delete any related BMM Routes
    DELETE FROM bmm_routes
    WHERE       site_id = :OLD.site_id
      AND       carrier = TRIM(:OLD.alpha_code);

  END IF;

END;
/

