用存储过程,根据id来更新两张表数据。

2025-03-25 21:00:47
推荐回答(1个)
回答1:

这也不用存储过程啊

update A set A.name=(select max(B.name) from B where B.id=A.id group by B.id) where exists (select 1 from B where A.id=B.id);

非用存储过程的话

create or replace procedure p_update_a
as
begin
update A set A.name=(select max(B.name) from B where B.id=A.id group by B.id) where exists (select 1 from B where A.id=B.id); 
commit;
end;

执行

begin
 p_update_a;
end;