Guest User

Untitled

a guest
Jan 20th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. cur_1 Sys_Refcursor;
  2.  
  3. cur_2 Sys_Refcursor;
  4.  
  5. v_1 VARCHAR2(30);
  6.  
  7. v_2 VARCHAR2(30);
  8.  
  9. v_3 VARCHAR2(30);
  10.  
  11. v_4 VARCHAR2(30);
  12.  
  13. OPEN cur_1 for Select * from tab1@dblink1;
  14.  
  15. Loop
  16.  
  17. Fetch cur_1 into v_1, v_2;
  18.  
  19. EXIT WHEN cur_1%NOTFOUND;
  20.  
  21. OPEN cur_2 for Select * from tab2@dblink1 where col1 = v_1 and col2 = v2;
  22.  
  23. Loop
  24.  
  25. Fetch cur2 into v_3, v_4;
  26.  
  27. Exit when cur_2%notfound;
  28.  
  29. INSERT INTO local.tab3 values (v_1,v_2, v_3, v_4);
  30.  
  31. END Loop;
  32.  
  33. close cur_2;
  34.  
  35. End Loop;
  36.  
  37. close cur_1;
  38.  
  39. .
  40.  
  41. .
  42.  
  43. .
  44.  
  45. .
  46.  
  47. insert into local.tab3(col1, col2, col3, col4)
  48. select tab1.col1, tab1.col2, tab2.col1, tab2.col2
  49. from tab1@dblink1 tab1
  50. join tab2@dblink1 tab2
  51. on tab1.col1 = tab2.col1
  52. and tab1.col2 = tab2.col2;
Add Comment
Please, Sign In to add comment