title: SQL - looping with distinct names
body: <p>I am new to SQL. I want to loop through my code with each distinct name from a table and I want to use that name in the rest of the program, so I would like that name in a variable.  Can anyone give any hints on how to accomplish this?  My idea was to store all the names from the table into an array (but i haven't been able to find how to make an array) or a list and loop through those names. Any help is appreciated.</p>
  
  <p>I'm continuing the work off of someone elses code, this may be pl/sql but heres some code just to give an idea of where im going</p>
  
  <pre><code>    CURSOR def_stud_pglts is
          select portal_objname_pgt, portal_row_num, portal_col_num, portal_objname
            from psprsmhpasgpglt
            where portal_name='EMPLOYEE' and portal_objname = 'NRPA_ACADEMICS'
            and portal_layoutbehav in ('2REQ', '3DEF');
  
          cursor name_cur is
          select distinct oprid from PSPRUHTABPGLT
              where portal_objname = 'NRPA_ACADEMICS';
  
         namerow name_cur%ROWTYPE;
         pageletRow def_stud_pglts%ROWTYPE;
         v_oprid VARCHAR2(30);
         tmp tmpcur;
         v_students NUMBER;
         v_min NUMBER;
  
         BEGIN
  
     select count(distinct oprid) 
      into v_students
      from (select distinct oprid from PSPRUHTABPGLT
      where portal_objname = 'NRPA_ACADEMICS');
  
       FOR pageletRow IN def_stud_pglts LOOP
      OPEN tmp FOR select count(oprid) from pspruhtabpglt 
     where portal_objname_pgt = pageletRow.portal_objname_pgt
       and portal_objname = 'NRPA_ACADEMICS'
     and portal_minimize=1;
      FETCH tmp INTO v_min;
      CLOSE tmp;
  
        INSERT INTO prtlpgltreport 
        VALUES (pageletRow.portal_objname_pgt, 
         'DEFAULT',NULL,v_min, v_clo, v_mov, pageletRow.portal_objname); 
    END LOOP;
  </code></pre>
  
  <p>So this is all working code. And i want to loop this while changing where it says 'NRPA_ACADEMICS' to other names in my table</p>