I have the following trigger that is not working. In the following trigger the statement:
and it always returns me 0 even though I have the values in LKUP_TBL.
Can someone please help why is that I always get the count 0. How can I fix this. Thanks
Code:
SELECT COUNT(*) into var1 FROM LKUP_TBL WHERE upper(FTCH) = var2;
and it always returns me 0 even though I have the values in LKUP_TBL.
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;
END FETCHINGVAL;
/
Can someone please help why is that I always get the count 0. How can I fix this. Thanks