title: cannot open SELECT query as cursor
body: <p>I am trying to construct a string from a table.  I need to construct a string from each row and then concatenate these strings (with an appropriate separator) together.  In a simple example the select produces a table with 3 rows; however, I get the message above.</p>
  
  <p>Can anyone help?  Thanks</p>
  
  <pre><code>for mFiles in 
      select url || pth || basename || '/' || basename || '.2.' || clientname into fName from files 
         where ( userId is null or uid != userId ) and (url is not null) and (pth is not null) 
            order by RANDOM() limit nImages LOOP
         res := res || fName || '|';
       RAISE NOTICE ' fName: % ' , fName;
     END LOOP;
  </code></pre>