日期:2014-05-17  浏览次数:21003 次

触发器只能用一次,就报ORA-04098
表格
SQL code

id varchar(100),
username varchar(100),
password varchar(100),
isAdmin varchar(1),




序列
SQL code
CREATE SEQUENCE seq_sys_userlist 
start with 100
increment by 1
MINVALUE 1
MAXVALUE 9999;


触发器
SQL code
create or replace trigger tri_sys_userlist       
before insert on t_sys_userlist       
for each row       
begin       
select 'u'||lpad(seq_sys_userlist.nextval,4,'0') into :new.id from dual;      
end ;  



执行
SQL code
insert into t_sys_userlist (username,userpassword,isadmin) values('amy','c8837b23ff8aaa8a2dde915473ce0991','0');
commit;

就报
ORA-04098:触发器无效且未通过重新验证

------解决方案--------------------
SQL code

--改成这样子,重新译下,应该就可以了
:new.id := 'u'||lpad(seq_sys_userlist.nextval,4,'0');