SQL*PLUS 触发器尚未编译但未显示错误

SQL*PLUS Trigger has not compiled but no errors shown up

我正在尝试使用 sqlplus 创建序列和触发器,所有内容都是根据 bash 脚本编写的。 我的代码如下

su -p oracle -c "$ORACLE_HOME/bin/sqlplus -l mydb/mypass@localhost:1521/xe << !
    create sequence SEQ_NAME start with 1000 maxvalue 9999;

    create or replace trigger TRG_NAME
    before insert on TABLE_NAME
    for each row
    begin
        select SEQ_NAME.nextval into :new.MY_ID from dual;
    end;
!
"

执行上述命令后,我预计会收到一些类似

的日志
Sequence created

Trigger compiled

但只出现日志Sequence created。结果,只创建了序列,没有创建触发器。我知道通过检查 SQL Developer tool

当我使用 SQL Developer 工具并执行脚本时

create sequence SEQ_NAME start with 1000 maxvalue 9999;

create or replace trigger TRG_NAME
before insert on TABLE_NAME
for each row
begin
select SEQ_NAME.nextval into :new.MY_ID from dual;
end;

那么一切正常!序列和触发器已创建!

对这个问题有什么想法吗?

试试这个,请告诉我们。

su -p oracle -c "$ORACLE_HOME/bin/sqlplus -l mydb/mypass@localhost:1521/xe << !
    create sequence SEQ_NAME start with 1000 maxvalue 9999
    /
    create or replace trigger TRG_NAME
    before insert on TABLE_NAME
    for each row
    begin
        select SEQ_NAME.nextval into :new.MY_ID from dual;
    end;
    /
!
"