mattn / go-oci8

Oracle driver for Go using database/sql
https://mattn.kaoriya.net/
MIT License
630 stars 212 forks source link

ORA-01406 when reading a large string with Queryrow(x) #308

Closed thigaz closed 5 years ago

thigaz commented 5 years ago

I was receiving the error above and coudn't figure out how to change the limit of the receiver. When I moved to Query(x) and Scan I stopped getting error, but received zero rows as response.

The string was from a VARCHAR2 with 2054 characters (the database field has a limitation of 2000 chars, don't know how it passed the limit, but there it was)

(the error ocurred with both queryrow and queryrowx)

mattn commented 5 years ago

Please show me minimal code to reproduce.

MichaelS11 commented 5 years ago

@thigaz Could you please provide SQL and Go code to reproduce, or close this issue?

thigaz commented 5 years ago

there you go (sorry for the long delay):

`package main

import ( "fmt" "log"

"github.com/jmoiron/sqlx"
"github.com/joho/godotenv"
_ "github.com/mattn/go-oci8"

)

var env = make(map[string]string)

func main() { var err error var datatemp string if env, err = godotenv.Read("./Configuracoes/DB.ENV"); err != nil { log.Fatal(err) } banco, err := sqlx.Open("oci8", fmt.Sprintf("%v/%v@%v", env["USUARIO"], env["SENHA"], env["SERVICO"])) if err != nil { log.Fatal(err) } defer banco.Close() if _, err = banco.Exec(fmt.Sprintf("ALTER SESSION SET CURRENT_SCHEMA = %s", env["SCHEMA"])); err != nil { log.Fatal(err) } if err = banco.QueryRowx( SELECT t.TDAT FROM pmobjt a, pmtext t WHERE a.OBJT = 1628249 AND a.cmmt = t.txid ORDER BY t.numr ).Scan(&datatemp); err != nil { log.Fatal(err) } fmt.Printf(datatemp) }`

Data in the field is a string with len=2024.

MichaelS11 commented 5 years ago

@thigaz Need sql as well.

thigaz commented 5 years ago

@thigaz Need sql as well.

It's in the body of the message:

SELECT t.TDAT FROM pmobjt a, pmtext t WHERE a.OBJT = 1628249 AND a.cmmt = t.txid ORDER BY t.numr

MichaelS11 commented 5 years ago

@thigaz All the SQL. In this case it looks like the two create tables and all the relevant inserts.

But really want is wanted is a self contained example, with all the needed SQL, create tables, insert statements, select statements, any PL/SQL, etc.

thigaz commented 5 years ago

It's a SAP PowerDesigner product database which I'm querying some fields. I didn't create the table nor its data. I'm able to retrieve the data using Goracle, but not with OCI8. I'll create a custom DB and see if I can simulate the same error.

MichaelS11 commented 5 years ago

Thank you. With a working example that reproduces the error, makes it so we can help reproduce and hopefully fix the issue.

MichaelS11 commented 5 years ago

This may just be a duplicate of https://github.com/mattn/go-oci8/issues/306 . If so, close this?

MichaelS11 commented 5 years ago

@mattn Close this?

thigaz commented 5 years ago

You guys can close it. It's been some rough months here and I don't know when I'll have time to focus on this issue. If you can create a VARCHAR2 column limited to 2000 chars with 2024+ chars and read it normally, the problem may be on my DB.

Anyway, thanks for being interested on my problem!

MichaelS11 commented 5 years ago

@thigaz Welcome. Could you close it?

MichaelS11 commented 5 years ago

@mattn Please close this.