表结果如下:
 名称                                      是否为空? 类型
 ----------------------------------------- -------- ----------------- USER_ID                                            NUMBER
 USER_NAME                                          VARCHAR2(15)
 USER_PASSWORD                                      VARCHAR2(15)触发器如下:
create or replace trigger sport_login_bir
   before insert  on sport_login
   for each row
begin
   insert into sport_login(user_id) values(sport_seq.nextval);
end;执行:insert into sport_login(user_name,user_password) values('002','002');
结果提示出错:
ERROR 位于第 1 行:
ORA-00036: 超过递归 SQL (50) 级的最大值
ORA-06512: 在"SCOTT.SPORT_LOGIN_BIR", line 2
ORA-04088: 触发器 'SCOTT.SPORT_LOGIN_BIR' 执行过程中出错
ORA-06512: 在"SCOTT.SPORT_LOGIN_BIR", line 2
ORA-04088: 触发器 'SCOTT.SPORT_LOGIN_BIR' 执行过程中出错
ORA-06512: 在"SCOTT.SPORT_LOGIN_BIR", line 2
ORA-04088: 触发器 'SCOTT.SPORT_LOGIN_BIR' 执行过程中出错
ORA-06512: 在"SCOTT.SPORT_LOGIN_BIR", line 2
ORA-04088: 触发器 'SCOTT.SPORT_LOGIN_BIR' 执行过程中出错
请问大虾位这是怎么回事呀?

解决方案 »

  1.   


    create or replace trigger sport_login_bir
       before insert  on sport_login
       for each row
    begin
       select sport_seq.nextval into :new.user_id from dual;
    end;
      

  2.   

    create or replace trigger sport_login_bir
       before insert  on sport_login
       for each row
    begin
       insert into sport_login(user_id) values(sport_seq.nextval);
    end;错误提示非常明确了,一个死循环的递归调用在表sport_login上创建的插入触发器中继续对表sport_login进行插入,所以再次触发触发器,触发器中又对表进行插入,又触发了插入触发器,继续插入,继续触发