尝试在表ORACLE中创建触发器时出错

时间:2013-09-23 12:13:08

标签: oracle

当我想在Toad中触发到我的桌子时,我收到了错误。

这样的代码:

create table SEIAPPS_MODEL(MODEL_NO NUMBER PRIMARY KEY, MODEL_NAME VARCHAR(100))

create sequence SEIAPPS_MODEL_SEQ
start with 1
increment by 1

CREATE OR REPLACE TRIGGER TR_SEIAPPS_MODEL
BEFORE INSERT
ON SEIAPPS_MODEL
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT SEIAPPS_MODEL_SEQ.nextval INTO :NEW.MODEL_NO FROM dual;
END;

我得到的错误是:     PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: ;

我错过了什么?

2 个答案:

答案 0 :(得分:1)

    create table SEIAPPS_MODEL(MODEL_NO NUMBER PRIMARY KEY, MODEL_NAME VARCHAR(100)) ;
--                                                                                 ^^^^
    create sequence SEIAPPS_MODEL_SEQ
    start with 1
    increment by 1
    ;
-- ^^^^

    CREATE OR REPLACE TRIGGER TR_SEIAPPS_MODEL
    BEFORE INSERT
    ON SEIAPPS_MODEL
    REFERENCING NEW AS NEW
    FOR EACH ROW
    BEGIN
    SELECT SEIAPPS_MODEL_SEQ.nextval INTO :NEW.MODEL_NO FROM dual;
    END;
    /
-- ^^^^

答案 1 :(得分:0)

您的查询没有语法错误。我不确定你为什么会收到错误。

我逐一执行了这些陈述,我能够执行所有三个成功的......