insert into rgTempCustomer@abc(cCustomerNo,vcCustName,vcContact,vcTel,vcFax,vcZipCode)
select Agent_code,Agent_name,Link_man,Tele_no,Fax_no,Post_code from s_abc_catalog where dl_status=0;
select * from s_abc_catalog where dl_status=0 for update;
update s_abc_catalog set dl_status=1 where dl_status=0;
commit;

解决方案 »

  1.   

    你的意思,是在insert 的时候,就把整个表锁住吗?
      

  2.   

    lock table tbname in row exclusive mode;
    insert ....
      

  3.   

    第二楼的可能会有一些问题,因为我插入的时候可能会花很多时间,譬如插入了10条,但是你select * from s_abc_catalog where dl_status=0 for update;可能会缩到11条,这样子还是会出错;
    第三楼:我就是这个意思,在insert 的时候,就把整个表锁住!
    第四楼:我看看能不能!呵呵!谢谢
      

  4.   

    lock table tbname in row exclusive mode;
    insert ....
    这种方法不行?
      

  5.   

    lock table tbname in row exclusive mode;
    insert ....
    这个方法不行,我刚刚写了个存储过程,
    create or replace procedure test is
    begin
    lock table s_abc_catalog in row exclusive mode;
    insert into rgTempCustomer@abc(cCustomerNo,vcCustName,vcContact,vcTel,vcFax,vcZipCode)
    select Agent_code,Agent_name,Link_man,Tele_no,Fax_no,Post_code from s_agent_catalog where dl_status=0;
    update s_abc_catalog set dl_status=1 where dl_status=0;
    commit;EXCEPTION
        WHEN OTHERS THEN
            ROLLBACK;
    end;
    我用test的方法来测试,我停在insert执行的后面,但是我另开一个程序,还是可以在s_abc_catalog 插入数据.这样就不符合我的要求了,我是希望我insert的时候锁住s_abc_catalog表,然后可以update,再释放表的锁,这样就可以保证不出错.各位大侠看看还有什么办法???
      

  6.   

    lock table s_abc_catalog in exclusive mode;row execlusive模式和exclusive模式不同
      

  7.   

    在insert前,加语句select count(*) from s_abc_catalog for update;
      

  8.   

    lock table s_abc_catalog in exclusive mode;--锁表
    执行你的插入!
    commit;--提交,自动解锁