title: Saving result set in variable using a cursor
body: <p>I have a problem using Oracle SQL to loop over a result set twice.</p>
  
  <p><strong>The problem</strong></p>
  
  <p>I have a cursor that gets me all foreign keys to a given table name. Using the result form this cursor, I loop through all the constraints and disable them. Then I perform a data import and then I need to loop over the same result set and enable them.</p>
  
  <pre><code>CURSOR c_fkeys_inn(tabellnavn IN VARCHAR2)
  IS
    SELECT table_name,constraint_name, status
    FROM user_constraints
    WHERE (r_constraint_name,r_owner) IN
      (SELECT constraint_name, owner
      FROM user_constraints
      WHERE owner   ='POP'
      AND table_name=upper(tabellnavn)
    )
    AND STATUS = 'ENABLED';
  </code></pre>
  
  <p><strong>What I would like to do</strong></p>
  
  <p>My brain jumps directly to a variable. I would like to perform the cursor just once, and then save the result from the cursor to a variable.</p>
  
  <p>Is this possible or are there anything I do to save the result from the cursor and loop twice?</p>