oracle Scott 用户在创建表序列之后,往表里插数据的时候一直报ora-04098触发器无效且未通过重新验证错误 15
这个是源码。。。我的全部财富值。。。createtablet_emp(empnoNumber(4)primarykey,enamevarchar(20),jobvarch...
这个是源码。。。我的全部财富值。。。
create table t_emp(
empno Number(4) primary key ,
ename varchar(20),
job varchar(20),
mgr Number(6) ,
hiredate date,
sal Number(20),
comm Number(20),
deptno Number(6)
) ;
---建立序列:
CREATE SEQUENCE SEQ_TEMP
INCREMENT BY 1
MINVALUE 1 --最小值
MAXVALUE 99999999 --最大值由NUMBER(8)
NOCYCLE --不打环
NOCACHE --不缓存
ORDER;
COMMIT;
--给Scott用户授权
grant create any trigger to Scott;
grant administer database trigger to Scott;
grant dba to scott;
---然后建立before的触发器:
CREATE OR REPLACE TRIGGER TRG_ADDTEMP
BEFORE INSERT ON T_EMP
FOR EACH ROW WHEN (NEW.empno is null)
BEGIN
SELECT SEQ_TEMP.NEXTVAL INTO :NEW.empno FROM DUAL; --:NEW.ID是新的值
END TRG_ADDTEMP;
insert into t_emp
( ename, job, mgr, hiredate, sal, comm, deptno)
values
( 'Loser', 'clerk', 3, to_date('19960512','yyyymmdd'), 800, null, 20); 展开
create table t_emp(
empno Number(4) primary key ,
ename varchar(20),
job varchar(20),
mgr Number(6) ,
hiredate date,
sal Number(20),
comm Number(20),
deptno Number(6)
) ;
---建立序列:
CREATE SEQUENCE SEQ_TEMP
INCREMENT BY 1
MINVALUE 1 --最小值
MAXVALUE 99999999 --最大值由NUMBER(8)
NOCYCLE --不打环
NOCACHE --不缓存
ORDER;
COMMIT;
--给Scott用户授权
grant create any trigger to Scott;
grant administer database trigger to Scott;
grant dba to scott;
---然后建立before的触发器:
CREATE OR REPLACE TRIGGER TRG_ADDTEMP
BEFORE INSERT ON T_EMP
FOR EACH ROW WHEN (NEW.empno is null)
BEGIN
SELECT SEQ_TEMP.NEXTVAL INTO :NEW.empno FROM DUAL; --:NEW.ID是新的值
END TRG_ADDTEMP;
insert into t_emp
( ename, job, mgr, hiredate, sal, comm, deptno)
values
( 'Loser', 'clerk', 3, to_date('19960512','yyyymmdd'), 800, null, 20); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询