写了一个自增列的触发器、序列,可是插入的时候老说触发器失败。请各位大侠帮忙看看。。感激不尽
/*创建表*/
create table USERS
(
ID NUMBER not null,
NAME VARCHAR2(50) not null,
PASSWORD VARCHAR2(50) not null
)/*创建序列*/
create sequence s_id increment by 1 start with 1 nomaxvalue nocycle;
/*创建触发器*/
create or replace trigger USERS_TRIGGER
before insert on USERS
referencing old as old_value new as new_value
for each row WHEN (new_value.id is null)
begin
Select s_id.nextval into: new_value.id from dual;
end;
/*插入数据*/
INSERT INTO USERS(NAME,PASSWORD) VALUES('AA','BB')
错误:trigger 'de_test.user_trigger' is invalid and failed re-validation另外from dual是什么意思呢?网上查了很多例子都有这个。。
/*创建表*/
create table USERS
(
ID NUMBER not null,
NAME VARCHAR2(50) not null,
PASSWORD VARCHAR2(50) not null
)/*创建序列*/
create sequence s_id increment by 1 start with 1 nomaxvalue nocycle;
/*创建触发器*/
create or replace trigger USERS_TRIGGER
before insert on USERS
referencing old as old_value new as new_value
for each row WHEN (new_value.id is null)
begin
Select s_id.nextval into: new_value.id from dual;
end;
/*插入数据*/
INSERT INTO USERS(NAME,PASSWORD) VALUES('AA','BB')
错误:trigger 'de_test.user_trigger' is invalid and failed re-validation另外from dual是什么意思呢?网上查了很多例子都有这个。。
解决方案 »
- Oracle 账号被锁定,求高手救命,急急急!!!~~
- 表级约束与列级约束的区别是什么?
- 高分求助:在日文linux上安装oracle遇到的问题
- [求助]关于database的shutdown过程
- oracle 有这种语句么?? select * from test where a like'[a-z]%'
- 同时Insert多条记录,其中一个字段自增,该怎么实现
- 谁要是真把这个问题解决了,我给500块钱,真的!
- ORA-00604: error occurred at recursive SQL level 1和ORA-00018: maximum number of sessions exceeded 是什么错误怎么解决 谢谢
- 请求帮忙,解决尴尬,原由:oracle9ias中的“门户”
- oracle 跨分区查询怎么写
- 查询相同txid的条数
- 使用vnc远程安装oracle时,当输入export DISPLAY=0.0.0.0:0.0 xhost +服务器就变得很慢.
/*创建触发器*/
create or replace trigger USERS_TRIGGER
before insert on USERS
for each row WHEN (new.id is null)
begin
:new.id:= s_id.nextval;
end;
begin
Select s_id.nextval into: new_value.id from dual;
end;
-------------------
应该改为:
begin
Select s_id.nextval into :new_value.id from dual;
end;