/*****************************************************************************
*
* Filename         - $user_trace_triggers$
*
*                     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         - Triggers for agents table.
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 1998
*
*****************************************************************************/
/****************************************************************************
* @(#)$Workfile:   kit_triggers.sql  $  $Revision:   1.2  $
*
* Revision History
*
* Note that user tagtrak is many users. For these users the user
* name is entered as the last line in the change description.
*
* $Log:   /pvcsarch/db_ora/db/source/live/triggers/kit_triggers.svl  $
* 
*    Rev 1.2   21 Jun 2001 15:04:24   tagtrak
* OR:
* CR:
* Re-baseline version 4.0.0 to include patches.
* 
*    Rev 1.1   02 Apr 1998 19:46:16   tagtrak
* OR:
* CR:
* REV:
* Initial Issue
* See label for concession
* 
*    Rev 1.0   26 Feb 1998 11:44:02   tagtrak
* OR:
* CR:
* REV:
* Initial core product version
*
****************************************************************************/

-- Before each insert into the kit table create a unique id for the id field in the kit table

CREATE OR REPLACE TRIGGER ti_kit
BEFORE INSERT ON kit
FOR EACH ROW
BEGIN

-- Assign the next sequential user_trace id

    SELECT
        kitid_gen.nextval
    INTO
        :new.id
    FROM
        dual;

-- For variable scanner PTCIDs force scanner_id to be the same as the kit_id

    IF :NEW.scanner_id IS NULL THEN
        :new.scanner_id := :new.id;
    END IF;
END;
/
