select 编号 from a where 使用标志1
and rownum <=1(随机取一个号)
FOR UPDATE NOWAIT SKIP LOCKED; (11.2以前版本)
用号。。。。。。。
update a set使用标志=1 where 编号= 上面取到的号
注意事务一致性即可。
Oracle Oracle 11.2 Update: The syntax "NOWAIT SKIP LOCKED" is not accepted in Oracle 11.2. The "NOWAIT" keyword and "SKIP LOCKED" keyword have become mutually exclusive. Remove the "NOWAIT" if you want to use "SKIP LOCKED".
By default, the transaction waits until the requested row lock is acquired. If you are not willing to wait to acquire the row lock, use either the NOWAIT clause of the LOCK TABLE statement (see Choosing a Locking Strategy) or the SKIP LOCKED clause of the SELECT FOR UPDATE statement.
If you can lock some of the requested rows, but not all of them, the SKIP LOCKED option skips the rows that you cannot lock and locks the rows that you can lock.