Trigger that prevents a candidate who has stayed in the penultimate place during the last two months you can apply for a new job
So what I need to do is to insert the data into the table ficha_inscricao
check if this candidate was not the one with the second worst classificacao_final.nota_final
CREATE OR REPLACE TRIGGER impede_candidato
BEFORE INSERT ON ficha_inscricao
WHEN (:new.candidatoBI = candidato.BI and
candidato.bi=classificacao_final.candidatoBI and
classificacao_final.nota_final ............)
DECLARE impedido EXCEPTION;
BEGIN
RAISE impedido;
EXCEPTION
WHEN impedido THEN RAISE_APPLICATION_ERROR (-20001, 'Não se pode inscrever');
END;
I tried to do with order by DESC
plus rownum=2
but could not get past syntax errors.