问题
I run the following statements in oracle sql developer using oracle 11g express as my database. I only run into problems when i try to create the trigger. I get the message -
TRIGGER AUTO_NUM_GEN compiled
Warning: execution completed with warning
The SQL-
CREATE TABLE myschema.mytable (mynums NUMBER PRIMARY KEY);
CREATE SEQUENCE myschema.seq_of_nums MINVALUE 1
START WITH 1 INCREMENT BY 1 CACHE 10;
CREATE OR REPLACE TRIGGER myschema.auto_num_gen
BEFORE INSERT ON myschema.mytable FOR EACH ROW
BEGIN SELECT seq_of_nums.nextval INTO :new.mynums FROM DUAL; end; /
What is my mistake and why won't it work ?
I ran the diagnostic query -
show errors trigger myschema.auto_num_gen;
And saw -
PLS-00103: Encountered the symbol "/" The symbol "/" was ignored
On the side, When the same code is run through java i also get the error -
java.sql.SQLSyntaxErrorException: ORA-04098: trigger
'MYTABLE.MYSCHEMA.AUTO_NUM_GEN ' is invalid and failed re-validation
回答1:
The slash / at the end is your enemy ! Remove it and the code works !
来源:https://stackoverflow.com/questions/12192124/trigger-auto-num-gen-compiled-warning-execution-completed-with-warning