title: How to set variables in a loop with oracle?
body: <p>I have a loop and a variable <code>v_rownum</code> and I want to set value for it:</p>
  
  <pre><code>        FOR donvi_rows IN v_donvi
          LOOP
              DECLARE
                 v_rownum number;
              SELECT r
              INTO v_rownum
              FROM
              (SELECT ROWNUM AS r, k.Id
              FROM don_vi k
              WHERE k.ParentId = 1 )
              WHERE Id = donvi_rows.Id;
  
          END LOOP;
  </code></pre>
  
  <p>But it throw a exception:</p>
  
  <pre><code>PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
  
     begin function pragma procedure subtype type &lt;an identifier&gt;
     &lt;a double-quoted delimited-identifier&gt; current cursor delete
     exists prior
  The symbol "begin" was substituted for "SELECT" to continue.
  </code></pre>
  
  <p>I'm currently studying Oracle. I don't know much about it. Please help me to resolve my problem.</p>