title: Running query multiple times with different parameter
body: <p>I would like to run the query within a loop.There are two tables and I would like to take id from one table and add new rows to the other table with new value added for each id.</p>
  
  <p>I have two tables as below:</p>
  
  <p>Profile table:</p>
  
  <pre><code>ID  NAME    VALUE
  1   AAA 111
  2   BBB 222
  3   CCC 333
  4   DDD 444 ```
  </code></pre>
  
  <p>Attribute table:</p>
  
  <pre><code>ID  ATTRIBUTE_ID    VALUE
  1       1            VAL1
  2       1            VAL2
  3       2            VAL2
  4       2            VAL3
  </code></pre>
  
  <p>Now I want to take each unique ID from profile table and insert a respective row in Attribute table with new value. The end table should look like this:</p>
  
  <pre><code>ID  ATTRIBUTE_ID    VALUE
  1       1            VAL1
  2       1            VAL2
  3       2            VAL2
  4       2            VAL3
  5       1            VAL4
  6       2            VAL4
  </code></pre>
  
  <p>I have tried following cursor and failed:</p>
  
  <pre><code>DECLARE
  -- Store the SELECT query in a cursor
    CURSOR l_cur IS SELECT DISTINCT(ID) FROM PROFILE table;  
  --Create a variable that will hold each result from the cursor
  l_cur_rec l_cur%ROWTYPE;
  
  BEGIN
  -- Open the Cursor so that we may retrieve results
    OPEN l_cur;  
    LOOP
  -- INSERT INTO another table
          INSERT INTO ATTRIBUTE table (ID, ATTRIBUTE_ID, PLATFORM_ID) 
          VALUES((select max(ID)+1 from ATTRIBUTE_PLATFORM), (l_cur) , VAL4);  
  -- EXIT the loop if there are no more results
      EXIT WHEN l_cur%NOTFOUND;     
    END LOOP;
  -- Close the cursor to release the memory
    CLOSE l_cur;
  END;
  </code></pre>