这是我的程序
use my_database;
drop procedure if exists sel_upd_ports;
delimiter $$
create procedure sel_upd_ports()
begin
drop temporary table if exists oneone;
start transaction;
create temporary table oneone as (select id,tt from table where status=0 limit 10 for update);
update table a join oneone b on a.id=b.id set status=1;
commit;
select * from oneone;
drop temporary table oneone;
end$$
delimiter ;
这就是我需要的:
-
这必须是一个程序
-
更新+选择查询应在事务中工作,以便我的应用程序可以并发
-
过程应返回结果集
这个过程可行,但我无法消除错误
ERROR 1746 (HY000): Can't update table 'table' while 'oneone' is being created.
一旦我删除了一个“用于更新”的锁,它就会消失。