I have a trigger below. It fires when an event occurs and an entry is made into the eventlog table. However, it seems that when the event happens in the same second, say a breaker TRIPS CLOSES and TRIPS all in the same second, only the first TRIP causes the trigger to fire. Looks like the trigger is busy firing on the first TRIP and the other CLOSE TRIP event won't fire. Shouldn't trigger events be queued some how?
DECLARE
-- CREATE VARIABLES FOR THIS TRIGGER
v_dtm VARCHAR2(255);
v_pt_name VARCHAR2(255);
v_short_name VARCHAR2(255);
v_v_short_name VARCHAR2(255);
v_id VARCHAR2(255);
v_v_id VARCHAR2(255);
v_sub VARCHAR2(255);
v_breaker VARCHAR2(255);
v_breaker_trim VARCHAR2(255);
v_gens_breaker VARCHAR2(255);
v_text VARCHAR2(255);
v_tag VARCHAR2(255);
v_v_tag VARCHAR2(255);
v_flag NUMBER;
CURSOR cur IS SELECT id, tag, short_name FROM lakdba.breaker_tags;
CURSOR cur2 IS SELECT breaker FROM lakdba.gens_not_acc;
--**************************************************************************
------------------------------------------------------------------------------
-----Determines Trip/Close--------------------------------
FUNCTION TRIPCLOSE (v_text VARCHAR2) RETURN VARCHAR2 IS
RETURN_VALUE VARCHAR2(3);
BEGIN
IF SUBSTR(trim(v_text), 1)='TRIP' THEN
RETURN_VALUE:='T';
ELSIF SUBSTR(trim(v_text), 1)='CLOSE' THEN
RETURN_VALUE:='C';
ELSIF SUBSTR(trim(v_text), 1)='CLOSE TRIP' THEN
RETURN_VALUE:='CT';
ELSIF SUBSTR(trim(v_text), 1)='TRIP CLOSE' THEN
RETURN_VALUE:='TC';
ELSIF SUBSTR(trim(v_text), 1)='TRIP CLOSE TRIP' THEN
RETURN_VALUE:='TCT';
ELSIF SUBSTR(trim(v_text), 1)='CLOSE TRIP CLOSE' THEN
RETURN_VALUE:='CTC';
ELSE
RETURN_VALUE:=NULL;
END IF;
RETURN(RETURN_VALUE);
END TRIPCLOSE;
---------------------------------------------------------------------------
BEGIN
v_flag:=0;
v_pt_name:=:new.pointname;
v_text:=SUBSTRnew.alarmtext,103);
--/*
--GETS THE POINTS WE DO WANT BY COMPARING ALL OF THE BREAKER OPERATION
--POINTNAMES TO ACCEPTABLE VALUES ENTERED INTO THE lakdba.breaker_tags TABLE.
OPEN cur; LOOP FETCH cur INTO v_id, v_tag, v_short_name;
EXIT WHEN NOT cur%FOUND;
IF INSTR(v_pt_name, v_id) > 0 THEN
v_text:=TRIPCLOSE(v_text);
IF v_text IS NOT NULL THEN
v_flag:=1;
v_v_tag:=v_tag;
v_v_id:=v_id;
v_v_short_name:=v_short_name;
END IF;
END IF;
END LOOP; CLOSE cur;
--*/
--FILTERS OUT THE POINTS WE DO WANT BY COMPARING ALL OF THE BREAKER OPERATION
--POINTNAMES TO UNACCEPTABLE VALUES ENTERED INTO THE lakdba.gens_not_acc TABLE.
--THESE ARE GENERATOR BREAKERS
OPEN cur2; LOOP FETCH cur2 INTO v_gens_breaker;
EXIT WHEN NOT cur2%FOUND;
IF INSTR(v_pt_name, v_gens_breaker) > 0 THEN
v_flag:=0;
END IF;
END LOOP; CLOSE cur2;
IF v_flag = 1 THEN
--/*-----Determines Sub--------------------------
IF v_v_tag='BREED' THEN
v_sub:='BRU';
ELSIF v_v_tag= 'RECL' THEN
v_sub:='RECBB';
ELSIF v_v_tag='CONT' THEN
v_sub:='CPU';
ELSIF v_v_tag='BUTTER' THEN
v_sub:='BKU';
ELSE
FOR i IN 1..LENGTH(v_pt_name) LOOP
IF SUBSTR(v_pt_name,i) < 'A' AND v_sub IS NULL THEN
v_sub:=SUBSTR(v_pt_name,1,i-1);
END IF;
END LOOP;
END IF;
--*/-------------------------------------------------
--/*-----Determines Breaker--------------------------
IF v_v_tag='RECL' THEN
--v_breaker:='REC' || Substrnew.pointname,1,INSTRnew.pointname,' ',1 ,1));
v_breaker:=v_v_short_name;
ELSIF v_v_tag='BREED' THEN
v_breaker:=v_v_short_name;
ELSIF v_v_tag='CONT' THEN
v_breaker:=v_v_short_name;
ELSIF v_v_tag='BUTTER' THEN
v_breaker:=v_v_short_name;
ELSIF v_v_tag='C-344' THEN
v_breaker:=v_v_short_name;
ELSIF v_v_tag='C-354' THEN
v_breaker:=v_v_short_name;
ELSE
v_breaker:=Substrnew.pointname,1,INSTRnew.pointname,' ',1 ,1));
END IF;
--*/--------------------------------------------------
--v_sub:='J';
--v_breaker:='J364';
--v_text:='T';
v_dtm:=to_char((LAKDBA.pk_lk_util.fn_utc2locnew.utctime)), 'yyyy/mm/dd HH24:MI:SS');
-- v_dtm:=to_charnew.utctime, 'yyyy/mm/dd HH24:MI:SS');
-------LIVE TABLE ON GISDB1----------
INSERT INTO BREAKERDBA.BREAKER@ISR2GISDB1(subs, breaker, tripclose, breakerdate, tagpos)
VALUES(trim(v_sub), trim(v_breaker), trim(v_text), v_dtm, 2);
--INSERT INTO LAKDBA.BREAKER(subs, breaker, tripclose, breakerdate)
------TEST TABLE ON GISDB1-----------
INSERT INTO BREAKERDBA.BREAKER_TEST@ISR2GISDB1(subs, breaker, tripclose, breakerdate, tagpos)
VALUES(trim(v_sub), trim(v_breaker), trim(v_text), v_dtm, 2);
------TEST TABLE ON ISR -------------
INSERT INTO LAKDBA.BREAKER(subs, breaker, tripclose, breakerdate, tagpos)
VALUES(trim(v_sub), trim(v_breaker), trim(v_text), v_dtm, 2);
END IF;
EXCEPTION
WHEN OTHERS THEN
return;
END;
jodom
LUCK - WHERE PREPARATION MEETS OPPORTUNITY!!
DECLARE
-- CREATE VARIABLES FOR THIS TRIGGER
v_dtm VARCHAR2(255);
v_pt_name VARCHAR2(255);
v_short_name VARCHAR2(255);
v_v_short_name VARCHAR2(255);
v_id VARCHAR2(255);
v_v_id VARCHAR2(255);
v_sub VARCHAR2(255);
v_breaker VARCHAR2(255);
v_breaker_trim VARCHAR2(255);
v_gens_breaker VARCHAR2(255);
v_text VARCHAR2(255);
v_tag VARCHAR2(255);
v_v_tag VARCHAR2(255);
v_flag NUMBER;
CURSOR cur IS SELECT id, tag, short_name FROM lakdba.breaker_tags;
CURSOR cur2 IS SELECT breaker FROM lakdba.gens_not_acc;
--**************************************************************************
------------------------------------------------------------------------------
-----Determines Trip/Close--------------------------------
FUNCTION TRIPCLOSE (v_text VARCHAR2) RETURN VARCHAR2 IS
RETURN_VALUE VARCHAR2(3);
BEGIN
IF SUBSTR(trim(v_text), 1)='TRIP' THEN
RETURN_VALUE:='T';
ELSIF SUBSTR(trim(v_text), 1)='CLOSE' THEN
RETURN_VALUE:='C';
ELSIF SUBSTR(trim(v_text), 1)='CLOSE TRIP' THEN
RETURN_VALUE:='CT';
ELSIF SUBSTR(trim(v_text), 1)='TRIP CLOSE' THEN
RETURN_VALUE:='TC';
ELSIF SUBSTR(trim(v_text), 1)='TRIP CLOSE TRIP' THEN
RETURN_VALUE:='TCT';
ELSIF SUBSTR(trim(v_text), 1)='CLOSE TRIP CLOSE' THEN
RETURN_VALUE:='CTC';
ELSE
RETURN_VALUE:=NULL;
END IF;
RETURN(RETURN_VALUE);
END TRIPCLOSE;
---------------------------------------------------------------------------
BEGIN
v_flag:=0;
v_pt_name:=:new.pointname;
v_text:=SUBSTRnew.alarmtext,103);
--/*
--GETS THE POINTS WE DO WANT BY COMPARING ALL OF THE BREAKER OPERATION
--POINTNAMES TO ACCEPTABLE VALUES ENTERED INTO THE lakdba.breaker_tags TABLE.
OPEN cur; LOOP FETCH cur INTO v_id, v_tag, v_short_name;
EXIT WHEN NOT cur%FOUND;
IF INSTR(v_pt_name, v_id) > 0 THEN
v_text:=TRIPCLOSE(v_text);
IF v_text IS NOT NULL THEN
v_flag:=1;
v_v_tag:=v_tag;
v_v_id:=v_id;
v_v_short_name:=v_short_name;
END IF;
END IF;
END LOOP; CLOSE cur;
--*/
--FILTERS OUT THE POINTS WE DO WANT BY COMPARING ALL OF THE BREAKER OPERATION
--POINTNAMES TO UNACCEPTABLE VALUES ENTERED INTO THE lakdba.gens_not_acc TABLE.
--THESE ARE GENERATOR BREAKERS
OPEN cur2; LOOP FETCH cur2 INTO v_gens_breaker;
EXIT WHEN NOT cur2%FOUND;
IF INSTR(v_pt_name, v_gens_breaker) > 0 THEN
v_flag:=0;
END IF;
END LOOP; CLOSE cur2;
IF v_flag = 1 THEN
--/*-----Determines Sub--------------------------
IF v_v_tag='BREED' THEN
v_sub:='BRU';
ELSIF v_v_tag= 'RECL' THEN
v_sub:='RECBB';
ELSIF v_v_tag='CONT' THEN
v_sub:='CPU';
ELSIF v_v_tag='BUTTER' THEN
v_sub:='BKU';
ELSE
FOR i IN 1..LENGTH(v_pt_name) LOOP
IF SUBSTR(v_pt_name,i) < 'A' AND v_sub IS NULL THEN
v_sub:=SUBSTR(v_pt_name,1,i-1);
END IF;
END LOOP;
END IF;
--*/-------------------------------------------------
--/*-----Determines Breaker--------------------------
IF v_v_tag='RECL' THEN
--v_breaker:='REC' || Substrnew.pointname,1,INSTRnew.pointname,' ',1 ,1));
v_breaker:=v_v_short_name;
ELSIF v_v_tag='BREED' THEN
v_breaker:=v_v_short_name;
ELSIF v_v_tag='CONT' THEN
v_breaker:=v_v_short_name;
ELSIF v_v_tag='BUTTER' THEN
v_breaker:=v_v_short_name;
ELSIF v_v_tag='C-344' THEN
v_breaker:=v_v_short_name;
ELSIF v_v_tag='C-354' THEN
v_breaker:=v_v_short_name;
ELSE
v_breaker:=Substrnew.pointname,1,INSTRnew.pointname,' ',1 ,1));
END IF;
--*/--------------------------------------------------
--v_sub:='J';
--v_breaker:='J364';
--v_text:='T';
v_dtm:=to_char((LAKDBA.pk_lk_util.fn_utc2locnew.utctime)), 'yyyy/mm/dd HH24:MI:SS');
-- v_dtm:=to_charnew.utctime, 'yyyy/mm/dd HH24:MI:SS');
-------LIVE TABLE ON GISDB1----------
INSERT INTO BREAKERDBA.BREAKER@ISR2GISDB1(subs, breaker, tripclose, breakerdate, tagpos)
VALUES(trim(v_sub), trim(v_breaker), trim(v_text), v_dtm, 2);
--INSERT INTO LAKDBA.BREAKER(subs, breaker, tripclose, breakerdate)
------TEST TABLE ON GISDB1-----------
INSERT INTO BREAKERDBA.BREAKER_TEST@ISR2GISDB1(subs, breaker, tripclose, breakerdate, tagpos)
VALUES(trim(v_sub), trim(v_breaker), trim(v_text), v_dtm, 2);
------TEST TABLE ON ISR -------------
INSERT INTO LAKDBA.BREAKER(subs, breaker, tripclose, breakerdate, tagpos)
VALUES(trim(v_sub), trim(v_breaker), trim(v_text), v_dtm, 2);
END IF;
EXCEPTION
WHEN OTHERS THEN
return;
END;
jodom
LUCK - WHERE PREPARATION MEETS OPPORTUNITY!!