title: Calling rows.Err() in a multiple result set query with rows.NextResultSet()
body: <p>I'm building a query with multiple result sets, following the example given, <a href="https://golang.org/src/database/sql/example_test.go" rel="nofollow noreferrer">here</a>. Important bits copied below for convenience.</p>
  
  <p>My question is, should <code>rows.Err()</code> be called after each <code>for rows.Next() {...}</code> loop, rather than once at the very end as shown in the example? Why / why not? My understanding is that <code>rows.Err()</code> will catch errors, <a href="https://golang.org/pkg/database/sql/#Rows.Err" rel="nofollow noreferrer">"... encountered during iteration"</a>, whereas <code>rows.NextResultSet()</code> will catch, <a href="https://golang.org/pkg/database/sql/#Rows.NextResultSet" rel="nofollow noreferrer">"... [errors] advancing to [the next result set]"</a>. Seems like I would want to catch errors during each iteration, no? Thanks!</p>
  
  <pre><code>rows, err := db.Query(q, age)
  if err != nil {
      log.Fatal(err)
  }
  defer rows.Close()
  
  for rows.Next() {
      var (
          id   int64
          name string
      )
      if err := rows.Scan(&amp;id, &amp;name); err != nil {
          log.Fatal(err)
      }
      fmt.Printf("id %d name is %s\n", id, name)
  }
  if !rows.NextResultSet() {
      log.Fatal("expected more result sets", rows.Err())
  }
  var roleMap = map[int64]string{
      1: "user",
      2: "admin",
      3: "gopher",
  }
  for rows.Next() {
      var (
          id   int64
          role int64
      )
      if err := rows.Scan(&amp;id, &amp;role); err != nil {
          log.Fatal(err)
      }
      fmt.Printf("id %d has role %s\n", id, roleMap[role])
  }
  if err := rows.Err(); err != nil {
      log.Fatal(err)
  }
  </code></pre>