Cursors and triggers
559101Feb 4 2007 — edited Feb 4 2007Hi, I have a question about cursors into triggers.
For example,if I´ve created a cursor on a table,and I´ve started Loop,Can I delete that table in the middle of the loop without problems? So I put this example:
CREATE OR REPLACE TRIGGER CTRL_EXT_REG
AFTER INSERT OR UPDATE OF EXTENSION ON REGIONS
DECLARE
TOTAL_EXT INTEGER;
TOTAL_EXT_P INTEGER;
CURSOR C1 IS SELECT DISTINCT * FROM COUNTRIES_MODIF;
COUNTRY NUMBER(2);
BEGIN
OPEN C1;
LOOP
FETCH C1 INTO COUNTRY;
EXIT WHEN C1%NOTFOUND;
SELECT SUM(EXTENSION) INTO TOTAL_EXT_P FROM COUNTRIES WHERE CODE=COUNTRY;
SELECT SUM(EXTENSION) INTO TOTAL_EXT FROM REGIONS R WHERE R.COUNTRY=COUNTRY;
IF(TOTAL_EXT > TOTAL_EXT_P) THEN
RAISE_APPLICATION_ERROR(-20004,'ERROR.TOTAL EXTENSION REGIONS ARE LARGER THAN TOTAL EXTENSION COUNTRY');
END IF;
--------> DELETE FROM PAISES_MODIF; <-------------------------------------------
END LOOP;
END;
So can I delete PAISES_MODIF and the cursor won´t have problems? I say that because cursor can have the info about this table although I deleted this table.
Sorry If I don´t have explained it very good.
Thanks
Message was edited by:
Ancalagon