Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. create x_table
  2. (
  3. id number,
  4. value varchar2(100)
  5. );
  6.  
  7. insert into x_table (id, value ) values (1, 'One');
  8. insert into x_table (id, value ) values (2, 'Two');
  9.  
  10. commit;
  11.  
  12. declare
  13.  
  14. cursor x_cur (p_id number) is
  15. select *
  16. from x_table;
  17.  
  18. type x_type is table of x_cur%rowtype index by pls_integer;
  19. x_rec x_type;
  20. x_rec2 x_type;
  21.  
  22. begin
  23.  
  24. open x_cur(1);
  25. fetch x_cur
  26. into x_rec;
  27. close x_cur;
  28.  
  29. open x_cur(2);
  30. fetch x_cur
  31. into x_rec2;
  32. close x_cur;
  33.  
  34. for i in 1..x_rec2 loop -- outer loop because this is the new record
  35.  
  36. for x in 1..x_rec loop -- outer loop because this is the old record
  37.  
  38. this_is_a_pkg.do_something(p_new_id => x_rec2(i).id
  39. p_old_value => x_rec(x).value)
  40.  
  41. end loop;
  42.  
  43. end loop;
  44.  
  45.  
  46. end;
  47.  
  48. declare
  49.  
  50. cursor x_cur (p_id number) is
  51. select *
  52. from x_table;
  53.  
  54. cursor x_cur2 (p_id number) is
  55. select *
  56. from x_table;
  57.  
  58. type x_type is table of x_cur%rowtype index by pls_integer;
  59. x_rec x_type;
  60. x_rec2 x_cur2;
  61.  
  62. begin
  63.  
  64. open x_cur(1);
  65. fetch x_cur
  66. into x_rec;
  67. close x_cur;
  68.  
  69. open x_cur(2);
  70. fetch x_cur
  71. into x_rec2;
  72. close x_cur;
  73.  
  74. for i in 1..x_rec2 loop -- outer loop because this is the new record
  75.  
  76. for x in 1..x_rec loop -- outer loop because this is the old record
  77.  
  78. this_is_a_pkg.do_something(p_new_id => x_rec2(i).id
  79. p_old_value => x_rec(x).value)
  80.  
  81. end loop;
  82.  
  83. end loop;
  84.  
  85.  
  86. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement