存储过程sp1的流程如下:
select table1
若有符合条件的数据,update table1 set flag=1,且update table2 set flag= 3.
若没有符合条件的数据, update table2 set flag=2
(table1, table2都有主键,存储过程中有事务控制)前段调用的程序流程:select table2 where flag=1 ,一条一条取出,进行少量运算,调用存储过程sp1。问题是:在存储过程中,若不加行级锁,会出现数据不一致情况。若加锁,又很慢,怎么办?