Because when executing my sql script when I get to the part of my autoincrementable triggers it stays in a loop?

0

Create some triggers so that my primary keys are autoincrementable at the time of inserting but at the time of executing my script everything executes well when you are going to execute the first trigger that is Trigger_idcomisario stays in a loop and begins to generate numbers Do you know what could be happening?

I'm using oracle 11g express

--secuencia 
create sequence Secuencia_comisario
  start with 1
  increment by 1
  nomaxvalue;


--Triggers
CREATE  TRIGGER Trigger_idcomisario;
BEFORE INSERT ON comisario
FOR EACH ROW
BEGIN
SELECT Secuencia_comisario.NEXTVAL INTO :NEW.id_comisario FROM DUAL;
END;
    
asked by Jctd 21.11.2017 в 02:31
source

1 answer

0

Although I do not fully understand what you mean by looping numbers, what I can tell you is that there are at least 2 problems with your CREATE TRIGGER .

  • There should not be a semicolon in this portion: CREATE TRIGGER Trigger_idcomisario;

  • You need to end each trigger creation statement with / .

  • Additionally, the reading of the sequence can be simplified a bit, so that the sentence CREATE TRIGGER would be as follows:

    CREATE TRIGGER Trigger_idcomisario
    BEFORE INSERT ON comisario
    FOR EACH ROW
    BEGIN
      :NEW.id_comisario := Secuencia_comisario.NEXTVAL;
    END;
    /
    
        
    answered by 21.11.2017 / 03:23
    source