我正在尝试使用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 工具
问题是当我使用 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;
然后一切正常!序列和触发器已创建!
对这个问题有任何想法吗?