execute block returns (id1 int, id2 int)
as
declare c1 cursor for (select id from procedure1 order by 1);
declare c2 cursor for (select id from procedure2 order by 1);
begin
   open c1; open c2;
   fetch c1 into id1;
   if (row_count=0) then exit;
   fetch c2 into id2;
   if (row_count=0) then exit;

   while (0=0) do begin
     if (id1 < id2) then begin
       fetch c1 into id1;
       if (row_count=0) then exit;
     end else
     if (id1 > id2) then begin
       fetch c2 into id2;
       if (row_count=0) then exit;
     end else begin
       suspend;
       fetch c1 into id1;
       if (row_count=0) then exit;
     end
   end
end

То же самое можно процедурой.

-- 
Сергей Смирнов.

Ответить