How I have to do to define and use a cursor?
I need to modify a value in a table, but this is inside the trigger. So I get a mutant table.
I think that creating a temporary table and using a cursor for fetching its values I can solve the problem.
Another idea?
CREATE TRIGGER td_eq before delete ON eq FOR EACH ROW
BEGIN
INSERT INTO tmp_eq VALUES ( : old.NroEq, : old.Anio)
END;
CREATE TRIGGER td_eq1 before delete ON eq
DECLARE Y NUMBER;
Act NUMBER;
CURSOR C IS SELECT NroEq FROM eq
BEGIN
OPEN C;
FETCH C INTO Y,
WHILE C%found LOOP
SELECT Act INTO Act FROM eq WHERE NroEq = Y;
IF Act = 1 THEN
/*to do something*/
END IF;
FETCH C INTO Y
END LOOP;
DELETE FROM tmp_eq;
END;
Besides, I have another problem:
In the body of a trigger o stored procedure I write the following statement
update Table_P
set Act = 0
where Table_P.N= X;
But the previous code do not update that attribute (Act) in Table_P
What's the problem?