我上面写错了:
create or replace trigger RATE
  after insert on mcc_ctrlcmd  
  for each row
declare
  -- local variables here
begin
  UPDATE vdis_companyrate SET  dqfy =dqfy-1 
  where vdis_companyrate.su_id=mcc_ctrlcmd.su_id;
end RATE;

解决方案 »

  1.   

    UPDATE vdis_companyrate SET  dqfy =1 
      from  vdis_companyrate,mcc_ctrlcmd
          where mcc_ctrlcmd.su_id=vdis_companyrate.su_id;
    这个语句啥意思??? 没看懂~~~
      

  2.   

    create or replace trigger RATE
      after insert on mcc_ctrlcmd  
      for each row
    declare
      -- local variables here
    begin
      UPDATE vdis_companyrate SET  dqfy =dqfy-1 
      where vdis_companyrate.su_id=:new.su_id;
    end RATE;
      

  3.   

    create or replace trigger RATE
      after insert on mcc_ctrlcmd  
      for each row
    declare
      -- local variables here
    begin
        UPDATE vdis_companyrate SET  dqfy =(select vdis_companyrate.dqfy-1 from mcc_ctrlcmd where mcc_ctrlcmd.su_id=vdis_companyrate.su_id);
    end RATE
      

  4.   

    update 没有这种语法吧,至少8i之前没有
    是9i的吗?
      

  5.   

    我还要更新另外一张表,是否在写一个update 语言create or replace trigger RATE
      after insert on mcc_ctrlcmd  
      for each row
    declare
      -- local variables here
    beginUPDATE vdis_aa SET  dqfy =dqfy-1 
      where vdis_companyrate.su_id=:new.su_id;UPDATE vdis_companyrate SET  dqfy =dqfy-1 
      where vdis_companyrate.su_id=:new.su_id;end RATE;
      

  6.   

    这句“UPDATE vdis_aa SET  dqfy =dqfy-1 
      where vdis_companyrate.su_id=:new.su_id;
    ”有问题
      

  7.   

    你在sqlplus中运行一下就知道了把:new.su_id换成任意的数值。
      

  8.   

    create or replace trigger RATE
      after insert on mcc_ctrlcmd  
      for each row
    declare
      -- local variables here
    beginUPDATE vdis_aa SET  dqfy =dqfy-1 
      where vdis_aa.su_id=:new.su_id;UPDATE vdis_companyrate SET  dqfy =dqfy-1 
      where vdis_companyrate.su_id=:new.su_id;end RATE;
    -------------------------------
    是这个意思吧!
      

  9.   

    是呀,该怎么写呢?想 dsf() 这样,只有第一个表的更新有用,第二个表的更新没有任何的作用
      

  10.   

    我建了两个触发器,为什么只执行一个:
    1。
    create or replace trigger CarRate
      after insert on mcc_ctrlcmd  
      for each row
    declare
      -- local variables here
    begin
      UPDATE vdis_carrate SET    vdis_carrate.dqfy=
      vdis_carrate.dqfy-vdis_carrate.mtfy 
      where vdis_carrate.su_id=:new.su_id;end CarRate;
    2。
    create or replace trigger CompanyRATE
      after insert on mcc_ctrlcmd  
      for each row
    declare
      -- local variables here
    begin/*
       UPDATE titles
       SET ytd_sales = ytd_sales + qty
       FROM RATE
       WHERE titles.title_id = inserted.title_id*/
    /*////////////////////////////*/UPDATE vdis_companyrate SET  dqfy =dqfy-mtfy 
      where vdis_companyrate.su_id=:new.su_id;
      
    --/////////////////////////////////////////////UPDATE vdis_carrate SET  dqfy =dqfy-mtfy 
      where vdis_carrate.su_id=:new.su_id;
      
    end CompanyRATE;其作用的只有第二个为什么?
      

  11.   

    不可能的,你在看看第二个表还有没有其他的触发器。
    SQL> CREATE OR REPLACE TRIGGER "SCOTT"."TEST_NEW1" BEFORE INSERT
      2      ON "TEST2"
      3      FOR EACH ROW
      4      declare
      5         i number;
      6       begin
      7         i := :new.id;
      8
      9         if i = 6 then
     10           update test3 set p1=222 where id=i;
     11           update test1 set p1=222 where id=i;
     12         end if;
     13       end;
     14  /Trigger created.SQL> select * from test1;        ID ZYZ1               P1 DOCTIME   LASTTIME
    ---------- ---------- ---------- --------- ---------
             1 333               333 01-JUL-02 01-JUL-02
             1 333               333 01-MAY-02 01-MAY-02
             1 333               333 20-AUG-02 20-AUG-02
            62 sdfds               6 01-JUL-02 01-JUL-02
            63 sdfds               6 01-JUL-02 01-JUL-02
             1 333               333 01-JUL-02 01-JUL-02
            83 sdfds               6 01-JUL-02 01-JUL-02
            91 sdfds               6 01-JUL-02 01-JUL-02
            92 sdfds               6 01-JUL-02 01-JUL-02
            93 sdfds               6 22-AUG-02 22-AUG-02
            94 sdfds               6 02-AUG-02 02-AUG-02        ID ZYZ1               P1 DOCTIME   LASTTIME
    ---------- ---------- ---------- --------- ---------
             2                       01-SEP-02 01-SEP-02
             1 333               333 01-SEP-02 01-SEP-02
             3                       01-SEP-02 01-SEP-02
             6 temp              111 01-JAN-02 01-JAN-02
             5 字符集                01-JUL-02 01-JUL-02
            16 sdfdsfsdf             01-JUL-02 01-JUL-02
            17 sdfdsfsd43            01-JUL-02 08-AUG-02
               43f        22 I'm a boy
            23 I'm a boy;        ID ZYZ1               P1 DOCTIME   LASTTIME
    ---------- ---------- ---------- --------- ---------
               '
    20 rows selected.SQL> select * from test2;        ID ZYZ1               P1
    ---------- ---------- ----------
            62                     3
             4 ryuy                5
             1                     1
             2 sdf                 5
             6 ssdfdf              7
            246 rows selected.SQL> select * from test3;        ID DOCTIME           P1 NEWZYZ               ZYZ1
    ---------- --------- ---------- -------------------- ----------
             6 01-JUL-01        111 2002-01-01
            22 01-JUL-01            1999-01-01
            22 01-JUL-01            2000-01-01
            83 24-SEP-02            asd                  sdf
            83 24-SEP-02            adfsd                dfsdf
            83 24-SEP-02            asd%df               dsfdsf%
             6 01-JUL-01        111 2002-01-01
            22 01-JUL-01            2001-01-018 rows selected.SQL> insert into test2 values (6,'sadfsdfsdfdf',66);1 row created.SQL> commit;Commit complete.SQL> select * from test3;        ID DOCTIME           P1 NEWZYZ               ZYZ1
    ---------- --------- ---------- -------------------- ----------
             6 01-JUL-01        222 2002-01-01
            22 01-JUL-01            1999-01-01
            22 01-JUL-01            2000-01-01
            83 24-SEP-02            asd                  sdf
            83 24-SEP-02            adfsd                dfsdf
            83 24-SEP-02            asd%df               dsfdsf%
             6 01-JUL-01        222 2002-01-01
            22 01-JUL-01            2001-01-018 rows selected.SQL> select * from test1;        ID ZYZ1               P1 DOCTIME   LASTTIME
    ---------- ---------- ---------- --------- ---------
             1 333               333 01-JUL-02 01-JUL-02
             1 333               333 01-MAY-02 01-MAY-02
             1 333               333 20-AUG-02 20-AUG-02
            62 sdfds               6 01-JUL-02 01-JUL-02
            63 sdfds               6 01-JUL-02 01-JUL-02
             1 333               333 01-JUL-02 01-JUL-02
            83 sdfds               6 01-JUL-02 01-JUL-02
            91 sdfds               6 01-JUL-02 01-JUL-02
            92 sdfds               6 01-JUL-02 01-JUL-02
            93 sdfds               6 22-AUG-02 22-AUG-02
            94 sdfds               6 02-AUG-02 02-AUG-02        ID ZYZ1               P1 DOCTIME   LASTTIME
    ---------- ---------- ---------- --------- ---------
             2                       01-SEP-02 01-SEP-02
             1 333               333 01-SEP-02 01-SEP-02
             3                       01-SEP-02 01-SEP-02
             6 temp              222 01-JAN-02 01-JAN-02
             5 字符集                01-JUL-02 01-JUL-02
            16 sdfdsfsdf             01-JUL-02 01-JUL-02
            17 sdfdsfsd43            01-JUL-02 08-AUG-02
               43f        22 I'm a boy
            23 I'm a boy;        ID ZYZ1               P1 DOCTIME   LASTTIME
    ---------- ---------- ---------- --------- ---------
               '
    20 rows selected.