I have the following trigger that is not working. In the following table
always returns me 0 even though I have the values in.Code:SELECT COUNT(*) into var1 FROM LKUP_TBL WHERE upper(FTCH) = var2;
On SVALD table whenever a record is inserted or updated my trigger is fired that checks if the value inserted in NVAL1 column of
SVALD table does exists in LKUP_TBL. And if it exists I am inserting in the NTBL table. But some how the second condition never gets executed
because var1 is 0.
Any help is appreciated thanks.Code:CREATE OR REPLACE TRIGGER FETCHINGVAL AFTER INSERT OR UPDATE ON SVALD FOR EACH ROW DECLARE var1 NUMBER; var2 VARCHAR2(10); BEGIN var1 := 0; IF :new.NVAL1 IS NOT NULL THEN var2 := UPPER(:new.NVAL1); SELECT COUNT(*) into var1 FROM LKUP_TBL WHERE upper(FTCH) = var2; END IF; IF var1 >= 1 THEN INSERT INTO NTBL (name, city, state) VALUES (:new.NAME, :new.CITY, :new.STATE); END IF; EXCEPTION WHEN OTHERS THEN -- Consider logging the error and then re-raise RAISE; END FETCHINGVAL; /


Reply With Quote
Bookmarks