Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Trigger - ORA-6512

Trigger - ORA-6512

From: Ricardo Patrocinio <conceicao.sousa_at_atm.mailcom.pt>
Date: Wed, 09 Jun 1999 10:52:26 +0100
Message-ID: <375E395A.B544D29@atm.mailcom.pt>


SqlPlus - Sql Server 7.3.2.2.

                         I've the following trigger:
                         Create or Replace Trigger TBI_RA1
                         Before Insert on Rime_Alteracoes for each row
                         Declare
                         Cursor C_dummy is
                         Select max(num_alteracao)
                         From rime_alteracoes
                         Where cod_projecto = :new.cod_projecto and
                         regiao = :new.regiao and
                         ano = :new.ano;

                         Cursor C_Crs Is
                         Select distinct 1
                         From rime_alteracoes
                         Where cod_projecto = :new.cod_projecto and
                         regiao = :new.regiao and
                         ano = :new.ano and
                         num_crs = :new.num_crs;

                         dummy rime_alteracoes.num_alteracao%TYPE := 0;
                         BEGIN

                         Open C_Crs;
                         Fetch C_Crs into dummy;
                         Close C_Crs;

                         If dummy = 1 Then
                         raise_application_error(-20100,'Coluna única
                         repetida');

                         Else
                         Open c_dummy;
                         Fetch c_dummy into dummy;
                         Close C_dummy;

                         if dummy is null then
                         dummy := 0;
                         else
                         dummy := dummy + 1;
                         end if;


:new.num_alteracao := dummy;
:new.login := USER;
End if; END; When I try to Insert a line in the table Rime_Alteracoes, it gives me the following errors: insert into rime_alteracoes (cod_projecto, regiao, ano, num_crs) values (1,'N',1997,1) * ERRO na linha 1: ORA-20100: Coluna única repetida ORA-06512: na "RIME.TBI_RA1", linha 21 ORA-04088: erro durante a execução do trigger 'RIME.TBI_RA1' The first one, I understand, it's the error that I've made and it should appear, but the other tow I don't understand!?
Received on Wed Jun 09 1999 - 04:52:26 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US