title: BigQuery Script: Loop over records of a table
body: <p>In BigQuery script, I'm trying to loop over records of a table and perform some operation for each record. I could not find direct approach where I can have something like below in script:</p>
  
  <pre><code>DECLARE record STRUCT&lt;id INT64, name STRING&gt;;
  
  LOOP (SELECT id, name FROM Testing.Employee)
    SET record = (id, name)
    -- Do something with record
  END LOOP;
  </code></pre>
  
  <p>I tried is to use ARRAY of STRUCT like below:</p>
  
  <pre><code>DECLARE all_rows ARRAY&lt;STRUCT&lt;id INT64, name STRING&gt;&gt;;
  SET all_rows = ( select as STRUCT id, name from Testing.Employees );
  </code></pre>
  
  <p>But it rightly gives type coerce error, as I'm trying to assign STRUCT to ARRAY type. Let me know if there is alternative for iterating over dataset.</p>