title: Oracle PL SQL: Comparing ref cursor results returned by two stored procs
body: <p>I was given a stored proc which generates an open cursor which is passed as output to a reporting tool. I re-wrote this stored proc to improve performance. What I'd like to do is to show that the two result sets are the same for a given set of input parameters. </p>
  
  <p>Something that is the equivalent of:</p>
  
  <pre><code>select * from CURSOR_NEW
  minus
  select * from CURSOR_OLD
       union all
  select * from CURSOR_OLD
  minus
  select * from CURSOR_NEW
  </code></pre>
  
  <p>Each cursor returns several dozen columns from a large subset of tables. Each row has an id value, and a long list of other column values for that id. I would want to check:</p>
  
  <ol>
  <li>Both cursors are returning the same set of ids (I already checked this)</li>
  <li>Both cursors have the same list of values for each id they have in common</li>
  </ol>
  
  <p>If it was just one or two columns, I could concatenate them and find a hash and then sum it up over the cursor.  Or another way might be to create a parent program that inserted the cursor results into a global temp table and compared the results. But since it's several dozen columns I'm trying to find a less brute force approach to doing the comparison. </p>
  
  <p>Also it would be nice if the solution was scalable for other situations that involved different cursors, so it wouldn't have to be manually re-written each time, since this is a situation I'm running into more often. </p>