-- This is a dummy file for now.
-- 
-- August 2001 E.Gallas/J.Simmons
-- Create the triggers which will set the values of the stat_used flags
------------------------------------------------------------------------

PROMPT Creating Triggers for stat_used flags

------------------------------------------------------------------------
----------------------------------------------------------------
--
--  stat_used_triggers.sql
--  Author: Jeremy Simmons 
--  
--  Desc: Creates triggers that control removal of data from a 
--        used trigger tree 
--  modified 20-Aug-2001 E.Gallas:  comment out drop trigger statements
--  modified 24-May-2002 J.Weigand: 
--           Removed (commented out) all delete triggers that changed the 
--           stat_used value to 'unused'.  This process cannot be performed
--           using Oracle triggers because, to be performed correctly, a
--           full scan of the table whose row is deleted is required and
--           Oracle will not allow this generating a 'mutating' table error.
--           This functionality is now being performed in the server.
--           The only problem with this will occur if sqlplus or any other
--           non-server process updates the database.  A new server method
--           (CheckStatUsed) has been added to the server to validate all
--           tables with a stat_used column and reset them to the correct
--           value.  These commented triggers can be removed from this file
--           at any time.
--
----------------------------------------------------------------


----------------------------------------------------------------
-- 
--                         LEVEL 1
--     
----------------------------------------------------------------

--drop trigger L1D_BINSERT_L1V_TRIG;

-- create trigger to update stat_used of L1_DIALOG on insert into L1_VALUES
PROMPT Creating Trigger 'L1D_BINSERT_L1V_TRIG'
CREATE OR REPLACE TRIGGER L1D_BINSERT_L1V_TRIG 
 BEFORE INSERT 
 ON L1_VALUES 
 FOR EACH ROW  
BEGIN 
UPDATE L1_DIALOGS SET stat_used='used'  
WHERE :new.pv_l1d_version>0
AND stat_used='unused' 
AND name=:new.pv_value 
AND version=:new.pv_l1d_version;
END L1D_BINSERT_L1V_TRIG;
/
----------------------------------------------------------------
--drop trigger L1D_BDELETE_L1V_TRIG;

-- create trigger to update stat_used of L1_DIALOG on DELETE into L1_VALUES
-- PROMPT Creating Trigger 'L1D_BDELETE_L1V_TRIG'
-- CREATE OR REPLACE TRIGGER L1D_BDELETE_L1V_TRIG 
--  BEFORE DELETE 
--  ON L1_VALUES 
--  FOR EACH ROW  
-- BEGIN 
-- UPDATE L1_DIALOGS SET stat_used='unused'  
-- WHERE :old.pv_l1d_version>0
-- AND stat_used='used' 
-- AND name=:old.pv_value 
-- AND version=:old.pv_l1d_version; 
-- END L1D_ADELETE_L1V_TRIG;
-- /
----------------------------------------------------------------
--drop trigger L1OT_BINSERT_L1V_TRIG;

-- create trigger to update stat_used of L1_OBJECTS on insert into L1_VALUES
PROMPT Creating Trigger 'L1OT_BINSERT_L1V_TRIG'
CREATE OR REPLACE TRIGGER L1OT_BINSERT_L1V_TRIG
 BEFORE INSERT 
 ON L1_VALUES 
 FOR EACH ROW  
BEGIN 
 UPDATE L1_OBJECTS SET stat_used='used'  
 WHERE stat_used='unused' 
 AND name=:new.name 
 AND version=:new.version;
 
END L1OT_BINSERT_L1V_TRIG;
/
----------------------------------------------------------------
--drop trigger L1OT_BDELETE_L1V_TRIG;

-- create trigger to update stat_used of L1_OBJECTS on delete into L1_VALUES
-- PROMPT Creating Trigger 'L1OT_BDELETE_L1V_TRIG'
-- CREATE OR REPLACE TRIGGER L1OT_BDELETE_L1V_TRIG
-- BEFORE DELETE 
-- ON L1_VALUES 
-- FOR EACH ROW  
-- BEGIN 
-- UPDATE L1_OBJECTS SET stat_used='unused'  
-- WHERE :old.pv_l1d_version>0
-- AND stat_used='used' 
-- AND name=:old.name 
-- AND version=:old.version;
--  
-- END L1T_BDELETE_L1V_TRIG;
-- /

-----------------------------------------------------------------
--drop trigger L1N_BINSERT_N_TRIG;

-- create trigger to update stat_used of NEOTYPES on insert into NEOTERMS
PROMPT Creating Trigger 'L1N_BINSERT_N_TRIG'
CREATE OR REPLACE TRIGGER L1N_BINSERT_N_TRIG
 BEFORE INSERT 
 ON NEOTERMS 
 FOR EACH ROW  
BEGIN 

 UPDATE NEOTYPES SET stat_used='used'  
 WHERE stat_used='unused' 
 AND intent=:new.intent 
 AND neotype=:new.neotype
 AND nty_version=:new.nty_version;

END L1N_BINSERT_N_TRIG;
/
-----------------------------------------------------------------
--drop trigger L1T_BINSERT_NTT_TRIG;

-- create trigger to update stat_used of L1_TERMS on insert into NEOTERM_TERMS
PROMPT Creating Trigger 'L1T_BINSERT_NTT_TRIG'
CREATE OR REPLACE TRIGGER L1T_BINSERT_NTT_TRIG
 BEFORE INSERT 
 ON NEOTERM_TERMS 
 FOR EACH ROW  
BEGIN 

 UPDATE L1_TERMS SET stat_used='used'  
 WHERE stat_used='unused' 
 AND t_name=:new.t_name 
 AND t_version=:new.t_version;

END L1T_BINSERT_NTT_TRIG;
/
-----------------------------------------------------------------
--drop trigger L1T_BDELETE_NTT_TRIG;

-- create trigger to update stat_used of L1_TERMS on DELETE into NEOTERM_TERMS
-- PROMPT Creating Trigger 'L1T_BDELETE_NTT_TRIG'
-- CREATE OR REPLACE TRIGGER L1T_BDELETE_NTT_TRIG
--  BEFORE DELETE 
--  ON NEOTERM_TERMS 
--  FOR EACH ROW  
-- BEGIN 
--  UPDATE L1_TERMS SET stat_used='unused'  
--  WHERE :old.t_version>0
--  AND stat_used='used' 
--  AND t_name=:old.t_name 
--  AND t_version=:old.t_version;
 
-- END L1T_BDELETE_NTT_TRIG;
-- /
----------------------------------------------------------------
--drop trigger NT_BINSERT_L1SN_TRIG;

-- create trigger to update stat_used of NEOTERMS on insert into L1S_ORDER_NS
PROMPT Creating Trigger 'NT_BINSERT_L1SN_TRIG'
CREATE OR REPLACE TRIGGER NT_BINSERT_L1SN_TRIG
 BEFORE INSERT 
 ON L1S_ORDER_NS 
 FOR EACH ROW  
BEGIN 

 UPDATE NEOTERMS SET stat_used='used'  
 WHERE stat_used='unused' 
 AND intent=:new.intent 
 AND neotype=:new.neotype
 AND nty_version=:new.nty_version
 AND nt_name=:new.nt_name;
END NT_BINSERT_L1SN_TRIG;
/
----------------------------------------------------------------
--drop trigger NT_BDELETE_L1SN_TRIG;

-- create trigger to update stat_used of NEOTERMS on insert into L1S_ORDER_NS
-- PROMPT Creating Trigger 'NT_BDELETE_L1SN_TRIG'
-- CREATE OR REPLACE TRIGGER NT_BDELETE_L1SN_TRIG
 -- BEFORE DELETE 
 -- ON L1S_ORDER_NS 
 -- FOR EACH ROW  
-- BEGIN 
 ----  UPDATE NEOTERMS SET stat_used='unused'  
 -- WHERE stat_used='used' 
 -- AND intent=:old.intent 
 -- AND neotype=:old.neotype
 -- AND nty_version=:old.nty_version
 -- AND nt_name=:old.nt_name;
-- END NT_BDELETE_L1SN_TRIG;
-- /
----------------------------------------------------------------
-- 
--                         LEVEL 2
--     
----------------------------------------------------------------



----------------------------------------------------------------
--drop trigger L2OG_BINSERT_L2V_TRIG;

-- create trigger to update stat_used of L2_OBJECTS or L2_GLOBAL on insert into L2_VALUES
PROMPT Creating Trigger 'L2OG_BINSERT_L2V_TRIG'
CREATE OR REPLACE TRIGGER L2OG_BINSERT_L2V_TRIG
 BEFORE INSERT 
 ON L2_VALUES 
 FOR EACH ROW  
BEGIN 
 UPDATE L2_OBJECTS SET stat_used='used'  
 WHERE stat_used='unused' 
 AND name=:new.name 
 AND version=:new.version
 AND obj_type=:new.obj_type 
 AND cvs_package=:new.cvs_package;

 UPDATE L2_GLOBALS SET stat_used='used'
 WHERE stat_used='unused'
 AND :new.pv_term_version>0
 AND t_name=:new.pv_value
 AND t_version=:new.pv_term_version;

END L2OG_BINSERT_L2V_TRIG;
/
-----------------------------------------------------------------

--drop trigger L2OG_BDELETE_L2V_TRIG;
-- -- create trigger to update stat_used of L2_OBJECTS or L2_GLOBALS on delete of L2_VALUES
-- PROMPT Creating Trigger 'L2OG_BDELETE_L2V_TRIG'
-- CREATE OR REPLACE TRIGGER L2OG_BDELETE_L2V_TRIG
 -- BEFORE DELETE 
 -- ON L2_VALUES 
 -- FOR EACH ROW  
-- BEGIN 
 -- UPDATE L2_OBJECTS SET stat_used='unused'  
 -- WHERE :old.pv_term_version>0
 -- AND stat_used='used' 
 -- AND name=:old.name 
 -- AND version=:old.version
 -- AND obj_type=:old.obj_type 
 -- AND cvs_package=:old.cvs_package;
-- 
 -- UPDATE L2_GLOBALS SET stat_used='unused'
 -- WHERE stat_used='used'
 -- AND t_name=:old.pv_value
 -- AND :old.pv_term_version>0
 -- AND t_version=:old.pv_term_version;
-- 
-- END L2OG_ADELETE_L2V_TRIG;
-- /
----------------------------------------------------------------
--drop trigger L2PP_BINSERT_L2PPTG_TRIG;

-- create trigger to update stat_used of L2PPS on insert into L2PP_TO_GS
PROMPT Creating Trigger 'L2PP_BINSERT_L2PPTG_TRIG'
CREATE OR REPLACE TRIGGER L2PP_BINSERT_L2PPTG_TRIG
 BEFORE INSERT 
 ON L2PP_TO_GS 
 FOR EACH ROW  
BEGIN 
 UPDATE L2PPS SET stat_used='used'  
 WHERE stat_used='unused' 
 AND pp_name=:new.pp_name 
 AND pp_version=:new.pp_version 
 AND pp_cvs_package=:new.pp_cvs_package;

 UPDATE L2_GLOBALS SET stat_used='used'
 WHERE stat_used='unused'
 AND t_name=:new.t_name
 AND t_version=:new.t_version;

END L2PP_BINSERT_L2PPTG_TRIG;
/

-----------------------------------------------------------------

--drop trigger L2PP_BDELETE_L2PP2GS_TRIG;
-- create trigger to update stat_used of L2PP on delete of L2PP_TO_GS
-- PROMPT Creating Trigger 'L2PP_BDELETE_L2PP2GS_TRIG'
-- CREATE OR REPLACE TRIGGER L2PP_BDELETE_L2PP2GS_TRIG
 -- BEFORE DELETE 
 -- ON L2PP_TO_GS 
 -- FOR EACH ROW  
-- BEGIN 
 -- UPDATE L2PPS SET stat_used='unused'  
 -- WHERE stat_used='used' 
 -- AND pp_name=:old.pp_name 
 -- AND pp_version=:old.pp_version 
 -- AND pp_cvs_package=:old.pp_cvs_package;
-- 
-- END L2PP_BDELETE_L2PP2GS_TRIG;
-- /

-----------------------------------------------------------------
--drop trigger L2G_BINSERT_L2ST_TRIG;

-- create trigger to update stat_used of L2_GLOBALS on insert into L2S_ORDER_GS
PROMPT Creating Trigger 'L2G_BINSERT_L2ST_TRIG'
CREATE OR REPLACE TRIGGER L2G_BINSERT_L2ST_TRIG
 BEFORE INSERT 
 ON L2S_ORDER_GS 
 FOR EACH ROW  
BEGIN 
 UPDATE L2_GLOBALS SET stat_used='used'  
 WHERE stat_used='unused' 
 AND t_name=:new.t_name 
 AND t_version=:new.t_version;

END L2T_BINSERT_L2ST_TRIG;
/
-----------------------------------------------------------------
--drop trigger L2G_BDELETE_L2ST_TRIG;

-- create trigger to update stat_used of L2_GLOBALS on delete into L2S_ORDER_GS
-- PROMPT Creating Trigger 'L2G_BDELETE_L2ST_TRIG'
-- CREATE OR REPLACE TRIGGER L2G_BDELETE_L2ST_TRIG
 -- BEFORE DELETE 
 -- ON L2S_ORDER_GS 
 -- FOR EACH ROW  
-- BEGIN 
 -- UPDATE L2_GLOBALS SET stat_used='unused'  
 -- WHERE :old.t_version>0
 -- AND stat_used='used' 
 -- AND t_name=:old.t_name 
 -- AND t_version=:old.t_version;
-- 
-- END L2T_BDELETE_L2ST_TRIG;
-- /

----------------------------------------------------------------


----------------------------------------------------------------
-- 
--                         LEVEL 3
--     
----------------------------------------------------------------

----------------------------------------------------------------
--drop trigger L3OT_BINSERT_L3V_TRIG;

-- create trigger to update stat_used of L3_OBJECTS or L3_TERM on insert into L3_VALUES
PROMPT Creating Trigger 'L3OT_BINSERT_L3V_TRIG'
CREATE OR REPLACE TRIGGER L3OT_BINSERT_L3V_TRIG
 BEFORE INSERT 
 ON L3_VALUES 
 FOR EACH ROW  
BEGIN 
 UPDATE L3_OBJECTS SET stat_used='used'  
 WHERE stat_used='unused' 
 AND name=:new.name 
 AND version=:new.version
 AND obj_type=:new.obj_type 
 AND cvs_package=:new.cvs_package;

 UPDATE L3_TERMS SET stat_used='used'
 WHERE stat_used='unused'
 AND :new.pv_term_version>0
 AND t_name=:new.pv_value
 AND t_version=:new.pv_term_version;

END L3OT_BINSERT_L3V_TRIG;
/ 
-----------------------------------------------------------------

--drop trigger L3OT_BDELETE_L3V_TRIG;
-- -- create trigger to update stat_used of L3_OBJECTS or L3_TERMS on delete of L3_VALUES
-- PROMPT Creating Trigger 'L3OT_BDELETE_L3V_TRIG'
-- CREATE OR REPLACE TRIGGER L3OT_BDELETE_L3V_TRIG
 -- BEFORE DELETE 
 -- ON L3_VALUES 
 -- FOR EACH ROW  
-- BEGIN 
 -- UPDATE L3_OBJECTS SET stat_used='unused'  
 -- WHERE stat_used='used' 
 -- AND name=:old.name 
 -- AND version=:old.version
 -- AND obj_type=:old.obj_type 
 -- AND cvs_package=:old.cvs_package;
--  
 -- UPDATE L3_TERMS SET stat_used='unused'
 -- WHERE stat_used='used'
 -- AND :old.pv_term_version>0
 -- AND t_name=:old.pv_value
 -- AND t_version=:old.pv_term_version;
-- 
-- END L3OT_BDELETE_L3V_TRIG;
-- /
----------------------------------------------------------------
--drop trigger L3T_BINSERT_L3ST_TRIG;

-- create trigger to update stat_used of L3_TERMS on insert into L3S_ORDER_FS
PROMPT Creating Trigger 'L3T_BINSERT_L3ST_TRIG'
CREATE OR REPLACE TRIGGER L3T_BINSERT_L3ST_TRIG
 BEFORE INSERT 
 ON L3S_ORDER_FS 
 FOR EACH ROW  
BEGIN 
 UPDATE L3_TERMS SET stat_used='used'  
 WHERE stat_used='unused' 
 AND t_name=:new.t_name 
 AND t_version=:new.t_version;
END L3T_BINSERT_L3ST_TRIG;
/
-----------------------------------------------------------------

--drop trigger L3T_BDELETE_L3ST_TRIG;
-- create trigger to update stat_used of L3_TERMS on delete of L3S_ORDER_Fs
-- PROMPT Creating Trigger 'L3T_BDELETE_L3ST_TRIG'
-- CREATE OR REPLACE TRIGGER L3T_BDELETE_L3ST_TRIG
 -- AFTER DELETE 
 -- ON L3S_ORDER_FS 
 -- FOR EACH ROW  
-- BEGIN 
 -- UPDATE L3_TERMS SET stat_used='unused'  
 -- WHERE stat_used='used'  
 -- AND :old.t_version>0 
 -- AND t_name=:old.t_name 
 -- AND t_version=:old.t_version;
-- 
-- END L3T_ADELETE_L3S_TRIG;
-- /
-- 
----------------------------------------------------------------
-- 
--                         TRIGGER LEVEL
--     
----------------------------------------------------------------

--drop trigger L123S_BINSERT_TNAME_TRIG;

-- create trigger to update stat_used of L1_SCRIPTS,L2_SCRIPTS,L3_SCRIPTS on insert into TRIGGER_NAMES
PROMPT Creating Trigger 'L123S_BINSERT_TNAME_TRIG'
CREATE OR REPLACE TRIGGER L123S_BINSERT_TNAME_TRIG
 BEFORE INSERT 
 ON TRIGGER_NAMES 
 FOR EACH ROW  
BEGIN 
 UPDATE L3_SCRIPTS SET stat_used='used'  
 WHERE stat_used='unused' 
 AND s_name=:new.l3s_name 
 AND s_version=:new.l3s_version;

 UPDATE L2_SCRIPTS SET stat_used='used'  
 WHERE stat_used='unused' 
 AND s_name=:new.l2s_name 
 AND s_version=:new.l2s_version;
 
 UPDATE L1_SCRIPTS SET stat_used='used'  
 WHERE stat_used='unused' 
 AND s_name=:new.l1s_name 
 AND s_version=:new.l1s_version;

END L123T_BINSERT_TNAME_TRIG;
/

----------------------------------------------------------------

--drop trigger L123S_BDELETE_TNAME_TRIG;

-- create trigger to update stat_used of L1_SCRIPTS,L2_SCRIPTS,L3_SCRIPTS on DELETE into TRIGGER_NAMES
-- PROMPT Creating Trigger 'L123S_BDELETE_TNAME_TRIG'
-- CREATE OR REPLACE TRIGGER L123S_BDELETE_TNAME_TRIG
 -- BEFORE DELETE 
 -- ON TRIGGER_NAMES 
 -- FOR EACH ROW  
-- BEGIN 
 -- UPDATE L3_SCRIPTS SET stat_used='unused'  
 -- WHERE :old.l3s_version>0
 -- AND stat_used='used' 
 -- AND s_name=:old.l3s_name 
 -- AND s_version=:old.l3s_version;
-- 
 -- UPDATE L2_SCRIPTS SET stat_used='unused'  
 -- WHERE :old.l2s_version>0
 -- AND stat_used='used' 
 -- AND s_name=:old.l2s_name 
 -- AND s_version=:old.l2s_version;
--  
 -- UPDATE L1_SCRIPTS SET stat_used='unused'  
 -- WHERE :old.l1s_version>0
 -- AND stat_used='used' 
 -- AND s_name=:old.l1s_name 
 -- AND s_version=:old.l1s_version;
-- 
-- END L123T_BDELETE_TNAME_TRIG;
-- /
----------------------------------------------------------------

--drop trigger TNAME_BINSERT_TLM_TRIG;

-- create trigger to update stat_used of TRIGGER_NAME on insert into TL_MAP
PROMPT Creating Trigger 'TNAME_BINSERT_TLM_TRIG'
CREATE OR REPLACE TRIGGER TNAME_BINSERT_TLM_TRIG
 BEFORE INSERT 
 ON TL_MAPS 
 FOR EACH ROW  
BEGIN 
 UPDATE TRIGGER_NAMES SET stat_used='used'  
 WHERE stat_used='unused' 
 AND name=:new.name 
 AND version=:new.version;

 UPDATE EXPOSURES SET stat_used='used'  
 WHERE stat_used='unused' 
 AND exg_name=:new.exg_name 
 AND exg_version=:new.exg_version;

END TNAME_BINSERT_TLM_TRIG;
/
----------------------------------------------------------------

--drop trigger TNAME_BDELETE_TLM_TRIG;

-- create trigger to update stat_used of TRIGGER_NAME on DELETE into TL_MAP
-- PROMPT Creating Trigger 'TNAME_BDELETE_TLM_TRIG'
-- CREATE OR REPLACE TRIGGER TNAME_BDELETE_TLM_TRIG
 -- BEFORE DELETE 
 -- ON TL_MAPS 
 -- FOR EACH ROW  
-- BEGIN 
 -- UPDATE TRIGGER_NAMES SET stat_used='unused'  
 -- WHERE :old.version>0
 -- AND stat_used='used' 
 -- AND name=:old.name 
 -- AND version=:old.version;
-- 
 -- UPDATE EXPOSURES SET stat_used='unused'  
 -- WHERE :old.exg_version>0
 -- AND stat_used='used' 
 -- AND exg_name=:old.exg_name 
 -- AND exg_version=:old.exg_version;
-- 
-- END TNAME_BDELETE_TLM_TRIG;
-- /
----------------------------------------------------------------
--drop trigger ED_BUPDATE_EX_TRIG;

-- create trigger to update stat_used of ENGAGED_DEVICES on update of EXPOSURES stat_used 
-- PROMPT Creating Trigger 'ED_BUPDATE_EX_TRIG'
-- CREATE OR REPLACE TRIGGER ED_BUPDATE_EX_TRIG
 -- BEFORE UPDATE OF STAT_USED 
 -- ON EXPOSURES 
 -- FOR EACH ROW  
-- BEGIN
-- IF :new.stat_used = 'used' THEN 
 -- UPDATE ENGAGED_DEVICES SET stat_used='used'  
 -- WHERE name in (select name from exposure_to_eds where exg_name = :new.exg_name and exg_version = :new.exg_version);
-- ELSE
 -- UPDATE ENGAGED_DEVICES SET stat_used='unused'  
 -- WHERE name in (select name from exposure_to_eds where exg_name = :new.exg_name and exg_version = :new.exg_version);
-- END IF;
-- END ED_BUPDATE_EX_TRIG;
-- /


----------------------------------------------------------------
--drop trigger ED_BINSERT_TLED_TRIG;

-- create trigger to update stat_used of ENGAGED_DEVICES on insert into TL_TO_ED
PROMPT Creating Trigger 'ED_BINSERT_TLED_TRIG'
CREATE OR REPLACE TRIGGER ED_BINSERT_TLED_TRIG
 BEFORE INSERT 
 ON TL_TO_EDS 
 FOR EACH ROW  
BEGIN 
 UPDATE ENGAGED_DEVICES SET stat_used='used'  
 WHERE stat_used='unused' 
 AND name=:new.name 
 AND version=:new.version;

END ED_BINSERT_TLED_TRIG;
/
----------------------------------------------------------------
--drop trigger ED_BDELETE_TLED_TRIG;

-- create trigger to update stat_used of ENGAGED_DEVICES on DELETE into TL_TO_ED
-- PROMPT Creating Trigger 'ED_BDELETE_TLED_TRIG'
-- CREATE OR REPLACE TRIGGER ED_BDELETE_TLED_TRIG
 -- BEFORE DELETE 
 -- ON TL_TO_EDS 
 -- FOR EACH ROW  
-- BEGIN 
 -- UPDATE ENGAGED_DEVICES SET stat_used='unused'  
 -- WHERE :old.version>0
 -- AND stat_used='used' 
 -- AND name=:old.name 
 -- AND version=:old.version;
-- 
-- END ED_BDELETE_TLED_TRIG;
-- /

----------------------------------------------------------------
--drop trigger ED_BINSERT_EXED_TRIG;

-- create trigger to update stat_used of ENGAGED_DEVICES on insert into EXPOSURE_TO_EDS
PROMPT Creating Trigger 'ED_BINSERT_EXED_TRIG'
CREATE OR REPLACE TRIGGER ED_BINSERT_EXED_TRIG
 BEFORE INSERT 
 ON EXPOSURE_TO_EDS 
 FOR EACH ROW  
BEGIN 
 UPDATE ENGAGED_DEVICES SET stat_used='used'  
 WHERE stat_used='unused' 
 AND name=:new.name 
 AND version=:new.version;

END ED_BINSERT_EXED_TRIG;
/

----------------------------------------------------------------
--drop trigger L1D_BEF_I;
-- create trigger to update stat_used of L1_DIALOGS on insert 
PROMPT Creating Trigger 'L1D_BEF_I'
CREATE OR REPLACE TRIGGER L1D_BEF_I
 BEFORE INSERT 
 ON L1_DIALOGS 
 FOR EACH ROW  
BEGIN 
 :new.stat_used:='unused';
END L1D_BEF_I;
/

----------------------------------------------------------------
--drop trigger NTY_BEF_I;
-- create trigger to update stat_used of NEOTYPES on insert 
PROMPT Creating Trigger 'NTY_BEF_I'
CREATE OR REPLACE TRIGGER NTY_BEF_I
 BEFORE INSERT 
 ON NEOTYPES 
 FOR EACH ROW  
BEGIN 
 :new.stat_used:='unused';
END NTY_BEF_I;
/

----------------------------------------------------------------
--drop trigger NT_BEF_I;
-- create trigger to update stat_used of NEOTERMS on insert 
PROMPT Creating Trigger 'NT_BEF_I'
CREATE OR REPLACE TRIGGER NT_BEF_I
 BEFORE INSERT 
 ON NEOTERMS 
 FOR EACH ROW  
BEGIN 
 :new.stat_used:='unused';
END NT_BEF_I;
/

----------------------------------------------------------------
--drop trigger L1O_BEF_I;
-- create trigger to update stat_used of L1_OBJECTS on insert 
PROMPT Creating Trigger 'L1O_BEF_I'
CREATE OR REPLACE TRIGGER L1O_BEF_I
 BEFORE INSERT 
 ON L1_OBJECTS 
 FOR EACH ROW  
BEGIN 
 :new.stat_used:='unused';
END L1O_BEF_I;
/

----------------------------------------------------------------
--drop trigger L2O_BEF_I;
-- create trigger to update stat_used of L2_OBJECTS on insert 
PROMPT Creating Trigger 'L2O_BEF_I'
CREATE OR REPLACE TRIGGER L2O_BEF_I
 BEFORE INSERT 
 ON L2_OBJECTS 
 FOR EACH ROW  
BEGIN 
 :new.stat_used:='unused';
END L2O_BEF_I;
/

----------------------------------------------------------------
--drop trigger L3O_BEF_I;
-- create trigger to update stat_used of L3_OBJECTS on insert 
PROMPT Creating Trigger 'L3O_BEF_I'
CREATE OR REPLACE TRIGGER L3O_BEF_I
 BEFORE INSERT 
 ON L3_OBJECTS 
 FOR EACH ROW  
BEGIN 
 :new.stat_used:='unused';
END L3O_BEF_I;
/

----------------------------------------------------------------
--drop trigger L1S_BEF_I;
-- create trigger to update stat_used of L1_SCRIPTS on insert 
PROMPT Creating Trigger 'L1S_BEF_I'
CREATE OR REPLACE TRIGGER L1S_BEF_I
 BEFORE INSERT 
 ON L1_SCRIPTS 
 FOR EACH ROW  
BEGIN 
 :new.stat_used:='unused';
END L1S_BEF_I;
/

----------------------------------------------------------------
--drop trigger L2S_BEF_I;
-- create trigger to update stat_used of L2_SCRIPTS on insert 
PROMPT Creating Trigger 'L2S_BEF_I'
CREATE OR REPLACE TRIGGER L2S_BEF_I
 BEFORE INSERT 
 ON L2_SCRIPTS 
 FOR EACH ROW  
BEGIN 
 :new.stat_used:='unused';
END L2S_BEF_I;
/

----------------------------------------------------------------
--drop trigger L3S_BEF_I;
-- create trigger to update stat_used of L3_SCRIPTS on insert 
PROMPT Creating Trigger 'L3S_BEF_I'
CREATE OR REPLACE TRIGGER L3S_BEF_I
 BEFORE INSERT 
 ON L3_SCRIPTS 
 FOR EACH ROW  
BEGIN 
 :new.stat_used:='unused';
END L3S_BEF_I;
/

----------------------------------------------------------------
--drop trigger L1T_BEF_I;
-- create trigger to update stat_used of L1_TERMS on insert 
PROMPT Creating Trigger 'L1T_BEF_I'
CREATE OR REPLACE TRIGGER L1T_BEF_I
 BEFORE INSERT 
 ON L1_TERMS 
 FOR EACH ROW  
BEGIN 
 :new.stat_used:='unused';
END L1T_BEF_I;
/

----------------------------------------------------------------
--drop trigger L2T_BEF_I;
-- create trigger to update stat_used of L2_GLOBALS on insert 
PROMPT Creating Trigger 'L2T_BEF_I'
CREATE OR REPLACE TRIGGER L2T_BEF_I
 BEFORE INSERT 
 ON L2_GLOBALS 
 FOR EACH ROW  
BEGIN 
 :new.stat_used:='unused';
END L2T_BEF_I;
/

----------------------------------------------------------------
--drop trigger L3T_BEF_I;
-- create trigger to update stat_used of L3_TERMS on insert 
PROMPT Creating Trigger 'L3T_BEF_I'
CREATE OR REPLACE TRIGGER L3T_BEF_I
 BEFORE INSERT 
 ON L3_TERMS 
 FOR EACH ROW  
BEGIN 
 :new.stat_used:='unused';
END L3T_BEF_I;
/

----------------------------------------------------------------
--drop trigger L2PP_BEF_I;
-- create trigger to update stat_used of L2PPS on insert 
PROMPT Creating Trigger 'L2PP_BEF_I'
CREATE OR REPLACE TRIGGER L2PP_BEF_I
 BEFORE INSERT 
 ON L2PPS 
 FOR EACH ROW  
BEGIN 
 :new.stat_used:='unused';
END L2PP_BEF_I;
/


----------------------------------------------------------------
--drop trigger TL_BEF_I;
-- create trigger to update stat_used of TRIGGER_LISTS on insert 
PROMPT Creating Trigger 'TL_BEF_I'
CREATE OR REPLACE TRIGGER TL_BEF_I
 BEFORE INSERT 
 ON TRIGGER_LISTS 
 FOR EACH ROW  
BEGIN 
 :new.stat_used:='unused';
END TL_BEF_I;
/

----------------------------------------------------------------
--drop trigger TN_BEF_I;
-- create trigger to update stat_used of TRIGGER_NAMES on insert 
PROMPT Creating Trigger 'TN_BEF_I'
CREATE OR REPLACE TRIGGER TN_BEF_I
 BEFORE INSERT 
 ON TRIGGER_NAMES 
 FOR EACH ROW  
BEGIN 
 :new.stat_used:='unused';
END TN_BEF_I;
/

----------------------------------------------------------------
--drop trigger EX_BEF_I;
-- create trigger to update stat_used of EXPOSURES on insert 
PROMPT Creating Trigger 'EX_BEF_I'
CREATE OR REPLACE TRIGGER EX_BEF_I
 BEFORE INSERT 
 ON EXPOSURES 
 FOR EACH ROW  
BEGIN 
 :new.stat_used:='unused';
END EX_BEF_I;
/

----------------------------------------------------------------
--drop trigger EN_BEF_I;
-- create trigger to update stat_used of ENGAGED_DEVICES on insert 
PROMPT Creating Trigger 'EN_BEF_I'
CREATE OR REPLACE TRIGGER EN_BEF_I
 BEFORE INSERT 
 ON ENGAGED_DEVICES 
 FOR EACH ROW  
BEGIN 
 :new.stat_used:='unused';
END EN_BEF_I;
/

----------------------------------------------------------------
--drop trigger TLS_BEF_I;
-- create trigger to update stat_used of TL_PSNAMES on insert 
PROMPT Creating Trigger 'TLS_BEF_I'
CREATE OR REPLACE TRIGGER TLS_BEF_I
 BEFORE INSERT 
 ON TL_PSNAMES 
 FOR EACH ROW  
BEGIN 
 :new.stat_used:='unused';
END TLS_BEF_I;
/
