我查询的sql语句如下,每个客户端都取lock_sign=N 且是排序后的第一条记录
select * from (select record_id,aa,bb from tab1 where lock_sign='N' order by cc)where rownum=1
查询之后马上执行update
update tab1 set lock_sign='Y' where record_id=某个值(我查处来的record_id)
**********问题是************
执行第一个select到执行第二个update在网慢时需要500毫秒,在这500毫秒其间就会有另一个客户端也访问到了这条记录
阁下有何高见 不让多个客户端同时访问同一条记录?
select * from (select record_id,aa,bb from tab1 where lock_sign='N' order by cc)where rownum=1
查询之后马上执行update
update tab1 set lock_sign='Y' where record_id=某个值(我查处来的record_id)
**********问题是************
执行第一个select到执行第二个update在网慢时需要500毫秒,在这500毫秒其间就会有另一个客户端也访问到了这条记录
阁下有何高见 不让多个客户端同时访问同一条记录?
之后加上for update nowait用来锁定特定的行
之后加上for update nowait用来锁定特定的行
所以其他客户端还是可以查到这条记录
但是不能修改这条记录
如果入库的时候全部都是Lock的,然后你再把它编程UNLock呢?
报告 ORA-02014错误
select * from tbl_auto_assign where record_id=
(select record_id from
(select * from tbl_auto_assign order by ADVANCE_SIGN desc,record_id) where rownum=1)
for update
我决的这样可以用for update来达到我的业务需求,我对for update的理解是:我锁定这一行更改提交之后其他用户才可以用同样的for update语句查询,更改不提交其他用户就一直等待。我不知道它与for update nowait的区别,有谁知道