oracle11新建一个主键自增的触发器报错问题

--触发器
CREATE
OR REPLACE TRIGGER tenant_info_trigger before INSERT ON tenant_info FOR each ROW

WHEN ( new.id IS NULL ) BEGIN
SELECT
seq_tenant_info.nextval INTO : new.id
FROM
dual;

END tenant_info_trigger;
> ORA-24344: success with compilation error

> Affected rows: 0
> 时间: 0.006s

因为new.id和:之间多一个空格,引起编译错误的原因很多,编写格式有问题算一种

改完以后效果

--触发器
CREATE 
    OR REPLACE TRIGGER config_info_aggr_trigger before INSERT ON config_info_aggr FOR each ROW
    
    WHEN ( new.id IS NULL ) BEGIN
    SELECT
        seq_config_info_aggr.nextval INTO :new.id 
    FROM
        dual;
    
END config_info_aggr_trigger;
> Affected rows: 0
> 时间: 0.007s

 

posted @ 2021-11-28 11:06  一心二念  阅读(243)  评论(0编辑  收藏  举报