title: Golang godror - execute a PL/SQL Cursor
body: <p>I'm trying to retrieve cursor result of a PL/SQL function in golang with godror.</p>
  
  <p><a href="https://github.com/godror/godror" rel="nofollow noreferrer">https://github.com/godror/godror</a></p>
  
  <blockquote>
    <p>Using cursors returned by stored procedures
    Use ExecContext and an interface{} or a database/sql/driver.Rows as the sql.Out destination, then either use the driver.Rows interface, or transform it into a regular *sql.Rows with godror.WrapRows, or (since Go 1.12) just Scan into *sql.Rows.</p>
  </blockquote>
  
  <pre><code>db, err := sql.Open("godror", "api/user@localhost/DEV")
  if err != nil {
    fmt.Println(err)
    panic(err)
  }
  defer db.Close()
  
  ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
  defer cancel()
  
  const query = `
  DECLARE
  BEGIN
  :cursor := pkg_api.my_func(pstr_logn_nm =&gt; 'my_name');
  END;
  `
  stmt, err := db.PrepareContext(ctx, query)
  if err != nil {
    fmt.Println(err)
    panic(err)
  }
  
  var rows driver.Rows
  _, err = stmt.ExecContext(ctx, sql.Out{Dest: &amp;rows})
  if err != nil {
    fmt.Println(err)
  }
  
  var r []driver.Value
  err = rows.Next(r)
  if err != nil {
    fmt.Println(err) // column count mismatch: we have 10 columns, but given 0 destination
  }
  defer rows.Close()
  
  fmt.Println(rows.Columns()) // [COL_1 COL_2 COL_3 COL_4 COL_5 COL_6 COL_7 COL_8 COL_9 COL_10]
  </code></pre>
  
  <p>I have an error: <code>column count mismatch: we have 10 columns, but given 0 destination</code>
  To my point of view it's because I have to define an interface with some columns.</p>
  
  <p>If I try to change <code>driver.Rows</code> by <code>sql.Rows</code> I have this error:</p>
  
  <blockquote>
    <p>arg: unknown type sql.Rows</p>
  </blockquote>
  
  <p>If I try to create an interface I:</p>
  
  <pre><code>type I interface {
    NM() string
  }
  
  var r []I
  err = rows.Next(r)
  </code></pre>
  
  <p>I have this error: <code>cannot use r (type []I) as type []driver.Value in argument to rows.Next</code></p>
  
  <p>I'm also new in Golang, if someone has an idea :)</p>
  
  <p>Thanks a lot!</p>