/*****************************************************************************
*
* Filename              - sys_interface_triggers.sql
*
* Project Name          - UltraTrak Database
*
* Description           - Triggers for SYS_INTERFACE table.
*                         When a row is inserted or updated it checks the
*                         STATUS column to ensure that a consistent set of
*                         values are being used. This is because the table
*                         is used by interfaces that were not originally
*                         written for UltraTrak, and so some STATUS mapping
*                         is required.
*
* Language              - Oracle PL/SQL
*
* File History          - For the development history run the Show History
*                         report in PVCS
*
* Copyright Ultra Electronics Airport Systems, 2007
*
*****************************************************************************/

/*
 * Before each insert or update into the sys_interface table
 */

CREATE OR REPLACE TRIGGER ti_sys_interface
BEFORE INSERT OR UPDATE ON sys_interface
FOR EACH ROW
BEGIN

   IF :new.status = 'A' THEN
      :new.status := 'AVAILABLE';
   ELSIF :new.status in ('N','D') THEN
      :new.status := 'UNAVAILABLE';
   END IF;

END;
/
