且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

多对多关系表不起作用无法从中删除值

更新时间:2023-11-17 17:33:16

您只能使用一个loop语句和variables(v_addressv_aid)在行之间进行比较,如下所示:在下面的块中:

You can use only one loop statement and variables( v_address and v_aid ) to make a comparison between the rows as in the block below :

declare
  v_address address.address%type;
  v_aid     address.aid%type;  
begin
 for i in (select aid ,address from address order by aid)
 loop  
    if nvl(v_address,'')=i.address then 
         update employee_add set aid=v_aid where aid=i.aid;  
         delete address where aid=i.aid;
    else
       v_address := i.address;
       v_aid := i.aid;   
    end if;
  end loop;
end;