go-ora icon indicating copy to clipboard operation
go-ora copied to clipboard

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

Open lifthelm opened this issue 1 year ago • 1 comments

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 avatar Jul 17 '24 15:07 lifthelm

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

lifthelm avatar Aug 05 '24 12:08 lifthelm

would you please give me example query that return multiple result set to test ad is that equal to returning multiple ref cursor from pl/sql block which I think is supported

sijms avatar May 17 '25 20:05 sijms

@sijms see https://python-oracledb.readthedocs.io/en/latest/user_guide/plsql_execution.html#implicit-results

cjbj avatar May 18 '25 23:05 cjbj

as I expected the execution will go to the line 1028 in command.go this area of code is incomplete I will complete and test

sijms avatar May 19 '25 21:05 sijms

support added in v2.9.0 and example code is present here

sijms avatar Jun 09 '25 21:06 sijms