How to read Image from Oracle (long raw format) in GoLang


(Gracy Layla) #1

I am trying to read images (in long raw datatype) from external Oracle database using Golang code.

When sql’s row.Next() is called following error is caught: ORA-01406: fetched column value was truncated

row.Next works fine for reading blob images from mssql DB.

Example code:

db, err := sql.Open("oci8", getDSN()) //function to get connection details 
    if err != nil {
        fmt.Println(err)
        return
    }
    defer db.Close()
    rows, err := db.Query("SELECT image FROM sysadm.all_images")
    if err != nil {
        fmt.Println(err)
        return
    }
    defer rows.Close()
    for rows.Next() {
       var id string
       var data []byte
       rows.Scan(&id, &data)    
    }
    fmt.Println("Total errors", rows.Err())
}

I hope someone can help me to fix this issue or pinpoint to problem area.


(Norbert Melzer) #2

Google told me, the result is too large for your program, you need to increase buffer sizes.

I have no clue though how to do so.