Create or replace procedure procname
is
begin
  update b set tag=2 where tag=0;
  insert into a (id , name, editdate )
  select id,name,editdate from b where tag=2;
  update b set tag=1 where tag=1;
end;
没有便宜,知己试试.

解决方案 »

  1.   

    没看太明白,会不会是这样:
    1.lock table b; -- 防止向A表写数据的过程中有新的数据写入
    2. insert into a(id , name, editdate )
         select id , name, editdate from b
         where tag = 1;
    3. update b set tag = 0 where tag = 1;
    4. commit;
      

  2.   

    是. 先将tag=2防止有新的数据进来, 到update b的时候就麻烦了.
      

  3.   

    为什么不给表b写一个insert触发器,有插入的时候,就往表a加一条相同纪录呢?
      

  4.   

    在B表中建建立触发器如下:CREATE OR REPLACE TRIGGER "KT_SJ"."TRI_B" BEFORE
    INSERT ON "AAAAA" FOR EACH ROW declare
    begin
       insert into a(id , name, editdate)values(:new.id,:new.name,:new.editdate);
       :new.tag:='0';    
    end;