Hi

I tried to use prepared statements and it works first time, but fails on 
second query. Ie code like

    tx, err := db.Begin()
    if err != nil {
        log.Fatalf("Error starting tx: %v", err)
    }
    defer tx.Rollback()
    st, err := tx.Prepare("select foo from t where id=?")
    if err != nil {
        log.Fatalf("Error preparing stmnt: %v", err)
    }
    defer st.Close()
    var n int
    err = st.QueryRow(1).Scan(&n)
    if err != nil {
        log.Fatalf("Error selecting(1): %v", err)
    }
    fmt.Println("[1] =", n)
    err = st.QueryRow(2).Scan(&n)
    if err != nil {
        log.Fatalf("Error selecting(2): %v", err)
    }
    fmt.Println("[2] =", n)

the first row value is printed OK but the second QueryRow fails with "Error 
op_response:0" message (this is with Firebird driver 
github.com/nakagami/firebirdsql). Both id's exist in the DB so single row 
is expected for both executions.
I also got error with "github.com/mattn/go-sqlite3" driver so I don't think 
this is a driver specific issue... either I use it the wrong way or there 
is a bug in the database/sql?

go version go1.8.1 linux/amd64

TIA
ain

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to