首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

大家帮忙看下~触发器~解决思路

2012-01-01 
大家帮忙看下~~触发器~~createorreplacetriggertrg_i_bdz_xlmc2003afterinsertonline_hour_xs2003foreachr

大家帮忙看下~~触发器~~
create   or   replace   trigger   trg_i_bdz_xlmc2003  
      after   insert  
      on   line_hour_xs2003
      for   each   row
declare  
      bdzmc   varchar2(30);
      xlmc     varchar2(30);
begin  
      bdzmc   :=   :new.bdzmc;
      xlmc   :=   :new.xlmc;
    if   (bdzmc!= " "   and   xlmc!= " ")     then  
        begin  
          if   (select   count(*)   from   bdz_xlmc2003   where   bdzmc=bdzmc   and   xlmc=xlmc)=0     then
          begin  
      insert   into   bdz_xlmc2003   values   (bdzmc,xlmc)   ;
          commit;
          exception   when   others   then  
          rollback;
          dbms_output.put_line( "Invalid   inserted ");
      end;
          end   if;
        end;
      end   if;
end;
该触发器运行时报错,if   (select   count(*)   from   bdz_xlmc2003   where   bdzmc=bdzmc   and   xlmc=xlmc)=0     then...报在这个地方,好像没有什么错吧。
请高手指点~~~

[解决办法]
先select into到一个变量,再判断变量。逻辑上的错误还有个就是变量名不能与字段同名。

热点排行