Iterate through a list of strings In SQL scriipt

I’m trying to create a sql file that iterates through a list and get me the information from a group of servers and save it on CSV file. The DB is Oracle, just in case :S.
I’m running the file using sqlplus in a playbook, so I’m able to change the query.

So far, I was able to do the following:

set markup csv on spool 'playbook-dir/roles/instances_db/files/servers.csv'  SELECT * FROM   (<some_internal_query>) WHERE  ROWNUM <= 600000 + 1 ORDER  BY server_name;    spool off 

This query will bring all 5000 servers and I just need 100 or so. I tried to add an array and loop around it Something like this:

DECLARE    arrayvalues sys.odcivarchar2list; BEGIN   arrayvalues := sys.odcivarchar2list('Matt','Joanne','Robert');   FOR x IN ( SELECT m.column_value m_value                FROM table(arrayvalues) m )   LOOP     SELECT *     FROM   (<some_internal_query>)     WHERE  ROWNUM <= 600000 + 1     ORDER  BY server_name;     END LOOP; END; 

But I got this error:

Error report - ORA-06550: line 7, column 1: PLS-00428: an INTO clause is expected in this SELECT statement 06550. 00000 -  "line %s, column %s:\n%s" *Cause:    Usually a PL/SQL compilation error. *Action: 

I’m not entirely sure if I’m doing the LOOP correctly.
Any help will be appreciated.