Creating a trigger in Oracle Express

后端 未结 4 515
面向向阳花
面向向阳花 2020-12-24 05:14

I was trying to do something like auto-increment in Oracle 11g Express and SQL Developer. I know very little about Oracle and I am also new to triggers.

I tried run

4条回答
  •  悲&欢浪女
    2020-12-24 05:45

    I am a novice at this so keep that in mind as I give my answer. I think the issue is that the code

    create or replace trigger insert_nums
    before insert on theschema.thetable
    for each row
    begin
    select test1_sequence.nextval into :new.id from dual;
    end;
    

    Is actually a script and not straight forward SQL statement. Hence you have to run the "Run Script". I discovered that when I had a worksheet open in SQL Developer that if I had anywhere in the worksheet the any code for trigger like above then even I just tried to run a statement that SQL Developer would look back in the worksheet and try to run the script. To stop that from happening I had to comment out the code. And If I did want to run the code for the trigger than I had to open a new worksheet, place the code there and do a RUN SCRIPT.

提交回复
热议问题