to_char(:new.lgsj,'hh24:mi:ss')<'18:00:00'改为
to_date(to_char(:new.lgsj,'hh24:mi:ss'))<to_date('18:00:00')

解决方案 »

  1.   

    错误信息:
    ORA-01843: not a valid month
    ORA-06512: at "T_INSERT", line 9
    ORA-04088: error during execution of trigger 'T_INSERT'
    wfeng907:我改了,还是不对。
      

  2.   

    上面是我改了后的错误,日期错误。
    下面是原来的错误信息:
    ORA-04091: table TableAis mutating, trigger/function may not see it
    ORA-06512: at "TableA", line 11
    ORA-04088: error during execution of trigger 'T_INSERT'
      

  3.   

    上面是我改了后的错误,日期错误。
    下面是原来的错误信息:
    ORA-04091: table TableAis mutating, trigger/function may not see it
    ORA-06512: at "TableA", line 6
    ORA-04088: error during execution of trigger 'T_INSERT'
      

  4.   

    sorry,是
    改为
    to_date(to_char(:new.lgsj,'hh24:mi:ss'),'hh24:mi:ss')<to_date('18:00:00','hh24:mi:ss')如果报错
    将11行'yyyy-mm-dd' 改为'yyyy-mon-dd'
      

  5.   

    但是这个语句可以通过的,说明可以用字符串进行比较的。
    select 1 from dual
    where to_char(sysdate,'hh24:mi:ss')<'18:00:00';
    莫非是:new.lgsj有问题?
      

  6.   

    wfeng7907(无风) 你这么改是有问题的。
    ORA-04091: table TableA  is mutating, trigger/function may not see it
    ORA-06512: at "T_INSERT", line 11
    ORA-04088: error during execution of trigger 'T_INSERT'
      

  7.   

    update TableA set tjsj=to_date(to_char(add_months(:new.lgsj,1),'yyyy-mm-dd'),'yyyy-mm-dd')改为下面的试试:
    update TableA set tjsj=trunc(add_months(:new.lgsj,1))
      

  8.   

    前面的update TableA set tjsj=to_date(to_char(:new.lgsj,'yyyy-mm-dd'),'yyyy-mm-dd')
    也改掉
    update TableA set tjsj=trunc(:new.lgsj)
      

  9.   

    你可以先把update都注释掉再运行,如果还错,就该是判断语句或者是:new.lgsj数据有问题.
      

  10.   

    ORA-04091 table string.string is mutating, trigger/function may not see it  Cause A trigger (or a user defined PL/SQL function that is referenced in this statement) attempted to look at (or modify) a table that was in the middle of being modified by the statement which fired it.  
    Action Rewrite the trigger (or function) so it does not read that table.  
    好象不是这些写法的问题!
      

  11.   

    if to_char(:new.lgsj,'hh24:mi:ss')<'18:00:00' then这句直接用if to_char(:new.lgsj,'hh24')<'18'试试,还有TableA set tjsj=to_date(to_char(:new.lgsj,'yyyy-mm-dd'),'yyyy-mm-dd')
    改为TableA set tjsj=:new.lgsj应该就可以了
      

  12.   

    duanzilin(寻) 
    你说的就是用trunc函数截取日期。
    好像与触发器不能使用没有关系的。
      

  13.   

    多谢大家关注,insert的触发器是直接修改:new.tjsj就可以了。
    我把成功的案例发给大家共享:)
    create or replace trigger t_insert
      before insert on TableA  --注意是before
      for each row
    declare
       stime varchar2(20);
      dtjsj1 date;
      dtjsj2 date;
    begin
    --获取时间
      select to_char(:new.lgsj,'hh24:mi:ss'),trunc(:new.lgsj),trunc(add_months(:new.lgsj,1))
        into stime,dtjsj1,dtjsj2 from dual;
      
      if stime<'18:00:00' then
       :new.tjsj := dtjsj1;--直接修改new.tjsj
      else
       :new.tjsj := dtjsj2;
      end if;
    end t_insert;