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



我正在尝试使用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开发人员工具

问题是当我使用SQL 开发人员工具并执行脚本时

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;
/
!
"

相关内容

最新更新