我写了一触发器如下
create or replace trigger pre_money_change
after insert or update of yx_mk on ydyy.pre_money
for each row
declare
countnum  number;
begin
if inserting then
select count(account_id) into countnum from ydyy.pre_money_01 where account_id=:new.account_Id;
if countnum==0 then
insert into ydyy.pre_money_01 values(:new.account_Id,:new.remain_je);
else
update ydyy.pre_money_01 set remain_je=:new.remain_je where account_id=:new.account_id;
end if;
else
update pre_money_01 set remain_je=(SELECT nvl(remain_je/100,0) from ydyy.pre_money where yc_srl=(select max(yc_srl) from ydyy.pre_money where account_id=:new.account_id));
end if;
end;提示错误
 PLS-00103: 遇到符号 "=" 当等待下列其中之一时 :
  ( - + all mod null
  <an identifier> <a double-quoted delimited-identifier>
  <a bind variable> <a number> <a single-quoted SQL string> any
  avg count max min prior some sql stddev sum variance请帮忙解决
谢谢

解决方案 »

  1.   

    create or replace trigger pre_money_change
    after insert or update of yx_mk on ydyy.pre_money
    for each row
    declare
    countnum  number;
    begin
    if inserting then
    select count(account_id) into countnum from ydyy.pre_money_01 where account_id=:new.account_Id;
    if countnum=0 then
    insert into ydyy.pre_money_01(account_Id,remain_je) values(:new.account_Id,:new.remain_je);
    else
    update ydyy.pre_money_01 set remain_je=:new.remain_je where account_id=:new.account_id;
    end if;
    else
    update pre_money_01 set remain_je=(SELECT nvl(remain_je/100,0) from ydyy.pre_money where yc_srl=(select max(yc_srl) from ydyy.pre_money where account_id=:new.account_id));
    end if;
    end;
    就ok了!
    SQL> create or replace trigger pre_money_change
      2  after insert or update of yx_mk on test.pre_money
      3  for each row
      4  declare
      5  countnum  number(12);
      6  begin
      7  if inserting then
      8  select count(account_id) into countnum from test.pre_money_01 where account_id=:new.account_Id;  9  if countnum=0 then
     10  insert into test.pre_money_01(account_id,remain_je)  values(:new.account_Id,:new.remain_je);
     11  else
     12  update test.pre_money_01 set remain_je=:new.remain_je where account_id=:new.account_id;
     13  end if;
     14  else
     15  update pre_money_01 set remain_je=(SELECT nvl(remain_je/100,0) from test.pre_money where yc_srl
    =(select max(yc_srl) from test.pre_money where account_id=:new.account_id));
     16  end if;
     17  end;
     18  /Trigger created.