alexbrainman / odbc

odbc driver written in go
BSD 3-Clause "New" or "Revised" License
359 stars 141 forks source link

SQL0104 - Message can not be translated successfully. #49

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Execute query on Windows 7 64-bit, Go version 1.3.1 64-bit

2.Sample program:
package main

import (
    _ "code.google.com/p/odbc"
    "database/sql"
    "fmt"
    "log"
)

func main() {
    db, err := sql.Open("odbc", `
        Driver=iSeries Access ODBC Driver;
        System=myhost;
        Uid=myuser;
        Pwd=mypass;`)
    if err != nil {
        log.Fatal(err)
    }
    defer db.Close()

    rows, err := db.Query("SELECT 1 FROM sysibm.sysdummy1")
    if err != nil {
        log.Fatal(err)  // Fails here
    }

    var number int
    for rows.Next() {
        rows.Scan(&number)
    }
    fmt.Println(number)
}

What is the expected output? What do you see instead?
Expected to print 1, instead prints:
2014/09/09 13:12:39 SQLPrepare: {42000} [IBM][System i Access ODBC Driver][DB2 
for i5/OS]SQL0104 - Error message text unavailable.
Message can not be translated successfully.

What version of the product are you using? On what operating system?
Go version 1.3.1, Windows 7 64-bit, odbc library from 8/15/14

Please provide any additional information below.
The exact code works well on Linux (Ubuntu Go version 1.2.1).  Similar code 
using Python/pyodbc works on Windows machine.  I was testing this a while back 
for writing services and I could have sworn it worked on Windows in some early 
testing, that would have been a couple versions of Go earlier.  I opened a 
stack overflow question but after finding that it indeed does work with this 
exact code on Linux have decided it must be an issue I should post here.

Original issue reported on code.google.com by cory.lut...@gmail.com on 9 Sep 2014 at 8:28

GoogleCodeExporter commented 9 years ago
Your program prints 1 on my computer. I am running windows xp sp3. I use 
version 9.00.07.00 of IBM odbc driver. I don't know anything about AS400 or 
odbc configuration / tracing / debugging options. I don't see how I can help 
you. The error message odbc returns is not very helpful.

Alex

Original comment by alex.bra...@gmail.com on 10 Sep 2014 at 5:24

GoogleCodeExporter commented 9 years ago
Thanks for the response.  

I did do local tracing but it really doesn't show anything that I thought 
looked out of place other than that error message.  I am guessing it is an 
encoding issue somehow but I'm not sure of where.

Just to double check I did a simple equivalent program to connect to mysql and 
it works just fine.  It does seem to connect to the iSeries on the Linux side 
which is odd but it is where I would end up using it to speed up some Python 
stuff anyway.

I guess at this point I am at a dead end on the windows side, I will continue 
to try it occasionally after any updates to any relevant parts (drivers, etc) 
but I guess for now I will just have to Linux only.

Original comment by cory.lut...@gmail.com on 11 Sep 2014 at 5:47

GoogleCodeExporter commented 9 years ago
Would you mind telling me how you connect from Linux to as400 (what software 
you use for odbc). It might give me some ideas. Thank you.

Alex

Original comment by alex.bra...@gmail.com on 15 Sep 2014 at 7:35

GoogleCodeExporter commented 9 years ago
Hi Alex,

I use unixodbc with the iSeries Access Linux Driver 
(iSeriesAccess-7.1.0-1.0.x86_64.rpm).  Other than that, I don't think I have 
anything out of the ordinary.  I can run the exact sample code and it works 
just fine with Go (1.2.1) on Ubuntu 14.04.

In looking around this morning it appears IBM has changed the packaging for 
iSeries Access, the file I listed above does not seem to be available now...  I 
will see if I can dig into what they have updated.

I did end up doing tracing on the windows machine and have both a pyodbc trace 
as well as a go odbc trace.  The only thing I really notice is I am using 32bit 
Python on Windows but 64bit Go.  On Linux everything would be 64bit.  I have 
attached them both just in case they are of any use.

Cory

Original comment by cory.lut...@gmail.com on 15 Sep 2014 at 3:49

Attachments:

GoogleCodeExporter commented 9 years ago
cory.lutton,

Thank you for sending LOG files. They are very helpful. Looking at the log, I 
noticed that you're not using latest version of code.google.com/p/odbc. The 
latest version is:

changeset:   37:78314be168c8
tag:         tip
user:        Alex Brainman <alex.brainman@gmail.com>
date:        Tue Sep 02 11:28:47 2014 +1000
summary:     odbc: better handling of string parameters

Please, upgrade and try again. Thank you.

Alex

Original comment by alex.bra...@gmail.com on 16 Sep 2014 at 1:24

GoogleCodeExporter commented 9 years ago
Alex,

I have a feeling I had several things going against me including being so new 
to Go.  After starting over with go get..., go install.., to make sure I had 
the latest version and it setup correctly it appears to be working on Windows 
just as it is in Linux.  Hard to say if it was that exact patch that resolved 
it but it is working great now.

Thanks so much as this opens up Go as an option for the projects I am working 
on!  

Cory

Original comment by cory.lut...@gmail.com on 16 Sep 2014 at 3:48

GoogleCodeExporter commented 9 years ago
Sounds good to me.

Alex

Original comment by alex.bra...@gmail.com on 17 Sep 2014 at 3:47