sijms / go-ora

Pure go oracle client
MIT License
789 stars 174 forks source link

Is NextResultSet implemented for driver.Rows in go-ora? #573

Open lifthelm opened 1 month ago

lifthelm commented 1 month ago

I am using go_ora.Connection.QueryContext(...) that returns driver.Rows.

I want to use NextResultSet call like in database/sql:Rows

go-ora version: 2.8.19

What I am trying to do:

...
conn, err := go_ora.NewConnection(connectionString, nil)
if err != nil {
    return err
}
...
err = conn.Open()
if err != nil {
    return err
}
...
driverRows, err := conn.QueryContext(ctx, query, args...)
if err != nil {
    return err
}

...
// driverRows.NextResultSet()?
for driverRows.NextResultSet() {
    for driverRows.Next(values) == nil {
        ...
    }
}

Maybe I should use as in Golang standard library?

nextResultSet, ok := rs.rowsi.(driver.RowsNextResultSet)
if !ok {
    doClose = true
    return false
}

// Lock the driver connection before calling the driver interface
// rowsi to prevent a Tx from rolling back the connection at the same time.
rs.dc.Lock()
defer rs.dc.Unlock()

rs.lasterr = nextResultSet.NextResultSet()
if rs.lasterr != nil {
    doClose = true
    return false
}

I tried to find implementation of NextResultSet in go-ora source code same as in godror: https://github.com/godror/godror/blob/010a6de91d2687e91c1563126d3b76578c9771b5/rows.go#L776-L814

But only found this commented line: https://github.com/sijms/go-ora/blob/78d53fdf18c31d74e7fc9e0ebe49ee1c6af0abda/v2/data_set.go#L24

lifthelm commented 1 month ago

As I see DataSet does not implement NextResultSet as DataSet can not be converted to driver.RowsNextResultSet