Open protamail opened 1 month ago
I found it being suggested to append "?lob fetch=post" to connect string to allow for more than 32K blob sizes to be fetched. Interestingly, adding that seems to solve the above issue as well. Still not clear how this works, is there a way to deal with it more explicitly?
starting from v2.8.8 the return size for inline lobs up to 1GB I will review the code for inline lobs and see if it can be modified to accept multiple calling for query
would you please test the following:
package main
import (
"database/sql"
"fmt"
_ "github.com/sijms/go-ora/v2"
"os"
)
func main() {
db, err := sql.Open("oracle", os.Getenv("DSN"))
if err != nil {
fmt.Println("can't open db: ", err)
return
}
defer func() {
err = db.Close()
if err != nil {
fmt.Println("can't close db: ", err)
}
}()
stmt, err := db.Prepare("SELECT TO_CLOB('this is a test') FROM DUAL")
if err != nil {
fmt.Println("can't prepare stmt: ", err)
return
}
defer func() {
err = stmt.Close()
if err != nil {
fmt.Println("can't close stmt: ", err)
}
}()
_, err = stmt.Query()
if err != nil {
fmt.Println("can't query #1: ", err)
return
}
_, err = stmt.Query()
if err != nil {
fmt.Println("can't query #2: ", err)
return
}
}
you should not close the rows
only close the stmt
I tested the code against v2.8.19 and it works. But only if query results are not being fetched. As soon as I add the following after the 1st query:
var clob string
for rows.Next() {
err = rows.Scan(&clob)
if err != nil {
fmt.Println(err)
}
}
The next query still reports: ORA-01002: fetch out of sequence
P.S. My app is a long running service where I prepare, cache, and reuse statements indefinitely. So in my case closing rows after each query is important to prevent memory leaks.
When reusing a prepared statement which selects a blob, I'm getting an "ORA-01002: fetch out of sequence" error. This happens only when selecting a blob column, even when no rows returned. Other select types work OK. Here's an example program I use. Notice how the repeating query() call results in the error (no error if stmt is closed after each query()):
The error output: