创建关键字自动增加的触发器出现问题了,求帮助
时间:2011-12-22
来源:互联网
SQL code
但是编译时有warning,而且真正插入语句时也无法插入,
SQL Error: ORA-04098: 触发器 'bef_ins_customer_autoid' 无效且未通过重新验证
04098. 00000 - "trigger '%s.%s' is invalid and failed re-validation"
*Cause: A trigger was attempted to be retrieved for execution and was
found to be invalid. This also means that compilation/authorization
failed for the trigger.
*Action: Options are to resolve the compilation/authorization errors,
disable the trigger, or drop the trigger
create sequence customerid increment by 1 start with 1 maxvalue 999999999 create or replace trigger bef_ins_customer_autoid before insert on customer referencing new as newrow for each row when(newrow.id is null) begin select customerid.nextval into :newrow.id from dual end;
但是编译时有warning,而且真正插入语句时也无法插入,
SQL Error: ORA-04098: 触发器 'bef_ins_customer_autoid' 无效且未通过重新验证
04098. 00000 - "trigger '%s.%s' is invalid and failed re-validation"
*Cause: A trigger was attempted to be retrieved for execution and was
found to be invalid. This also means that compilation/authorization
failed for the trigger.
*Action: Options are to resolve the compilation/authorization errors,
disable the trigger, or drop the trigger
作者: qinghuer 发布时间: 2011-12-22
实测创建触发器
SQL code
实测结果:
SQL code
CREATE OR REPLACE TRIGGER bef_ins_customer_autoid BEFORE INSERT ON Customer REFERENCING NEW AS newrow FOR EACH ROW WHEN (newrow.id IS NULL) BEGIN SELECT customerid.nextval into :newrow.id FROM dual; END;
实测结果:

作者: LuiseRADL 发布时间: 2011-12-22
学习了
作者: gaozhenchao_jia 发布时间: 2011-12-22
引用 1 楼 luiseradl 的回复:
实测创建触发器
SQL code
CREATE OR REPLACE TRIGGER bef_ins_customer_autoid
BEFORE INSERT ON Customer
REFERENCING NEW AS newrow
FOR EACH ROW
WHEN (newrow.id IS NULL)
BEGIN
SELECT customerid.nextval into……
实测创建触发器
SQL code
CREATE OR REPLACE TRIGGER bef_ins_customer_autoid
BEFORE INSERT ON Customer
REFERENCING NEW AS newrow
FOR EACH ROW
WHEN (newrow.id IS NULL)
BEGIN
SELECT customerid.nextval into……
嗯?这是什么情况?为什么我这边执行SQL code
insert into Customer(id,name,phonenum,address) values (null,'xiaowang','1412341234','beijing')
总是出现错误呢?我用的oracle sqldeveloper 会不会和这个有关系?但是不应该啊?
作者: qinghuer 发布时间: 2011-12-22
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28