estou tentando fazer uma trigger com cursor.
mais quando testo ela, aparecer um erro de cursor invalido.
segue o código abaixo
muito obrigado desde já.
create or replace TRIGGER trg_tb_usuario
BEFORE INSERT
ON Usuario REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW
declare
cursor c_EstAlunom is
select Quantidade, NOME_USUARIO
from Estatisticas_Usuario;
v_existe number;
v_aluno varchar2(100);
begin
LOOP
FETCH c_EstAlunom into v_existe, v_aluno;
if v_existe > 0 then
update Estatisticas_Usuario eu
set Quantidade = v_existe + 1 , nome_usuario = :NEW.Nome_aluno;
else
insert into Estatisticas_Usuario values(1, :NEW.Nome_aluno);
end if;
end loop;
close c_EstAlunom;
end;