-
Hi, I have a small comprehension problem, I try to figure out why Next_() does not return false when there's no more fetch to do, instead the loop run for the number of rows. A simplified and commented example with no specific logic, just to expose the question. package main
import (
"fmt"
"os"
go_ora "github.com/sijms/go-ora/v2"
)
func main() {
var err error
MsgErrorDie := func(msgText string, msgError error) {
if msgError != nil {
fmt.Println(msgText, msgError)
os.Exit(1)
}
}
DB, err := go_ora.NewConnection("oracle://tracnac:tracnac@192.168.122.90/xepdb1")
MsgErrorDie("URL error: ", err)
err = DB.Open()
MsgErrorDie("DB open error: ", err)
defer DB.Close()
stmt := go_ora.NewStmt("select rownum as num from all_objects where rownum <= 25", DB)
defer stmt.Close()
rows, err := stmt.Query_(nil)
MsgErrorDie("Query error: ", err)
defer rows.Close()
// We are fine here, 25 lines
for k, v := range rows.Rows {
fmt.Println(k, v)
}
count := 0
for rows.Next_() { // There's no more fetch to do, why the method does not return False ?
count += 1
}
// count = 25, it's the number of lines from the initial query fetch !?
fmt.Println("Next count: ", count)
} Thanks Yvan |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Humm another questions... Thanks Yvan
|
Beta Was this translation helpful? Give feedback.
-
HI Yvan for k, v := range rows.Rows {
fmt.Println(k, v)
} will be only 50 rows which is actually the value of prefetch rows count := 0
for rows.Next_() {
count += 1
}
fmt.Println("Next count: ", count) will be 90 |
Beta Was this translation helpful? Give feedback.
-
I will make a commit and hide all these parameters:
all these fields are used internally by DataSet to receive parameter from network and build necessary memory for reading operation |
Beta Was this translation helpful? Give feedback.
HI Yvan
getting rows using dataSet.Rows is not correct because dataSet.Rows is an internal buffer act like circular buffer
to explain it more clear
repeat your query as follow:
select rownum as num from all_objects where rownum <= 90
the result of:
will be only 50 rows which is actually the value of prefetch rows
but the result of:
will be 90
thus Next will act like forward-only cursor that retrieve any number of rows and only allocation memory that you defined by "PREFETCH_ROWS" url parameter