Hi,
MY CODE IS:
package main
import (
_ "github.com/ibmdb/go_ibm_db"
"fmt"
"database/sql"
"math/rand"
)
func main(){
con:="HOSTNAME=10.45.6.33;PORT=50000;DATABASE=go;UID=*****;PWD=********"
db,err:=sql.Open("go_ibm_db",con)
if err != nil{
fmt.Println(err)
}
defer db.Close()
db.Exec("DROP table byt1")
_,err=db.Query("create table byt1(name INT)")
if err != nil{
fmt.Println(err)
}
st1,err:=db.Prepare("select name from byt1 ORDER BY name DESC")
if err != nil{
fmt.Println(err)
}
st2,err:=db.Prepare("Insert into byt1(name) values(?)")
if err != nil{
fmt.Println(err)
}
for n := 1; n <= 3; n++ {
if _, err := st2.Exec(n); err != nil {
fmt.Println("insert(%d) = %v", n, err)
}
}
const nRuns = 10
ch := make(chan bool)
for i := 0; i < nRuns; i++ {
go func() {
defer func() {
ch <- true
}()
for j := 0; j < 10; j++ {
count := 0
if err := st1.QueryRow().Scan(&count); err != nil && err != sql.ErrNoRows {
fmt.Println("Query: %v", err)
return
}
if _, err := st2.Exec(rand.Intn(100)); err != nil {
fmt.Println("Insert: %v", err)
return
}
}
}()
}
for i := 0; i < nRuns; i++ {
<-ch
}
}
ERROR IS:
panic: runtime error: cgo argument has Go pointer to Go pointer
goroutine 16 [running]:
github.com/ibmdb/go_ibm_db/api.SQLBindCol.func1(0x4000100010001, 0xc00005a3f8, 0xc000000004, 0xc00005a3d8, 0x4edfe0)
/home/rakhil/go/src/github.com/ibmdb/go_ibm_db/api/zapi_unix.go:26 +0x4c
github.com/ibmdb/go_ibm_db/api.SQLBindCol(0x4000100010001, 0xc00005a3f8, 0x4, 0xc00005a3d8, 0x0)
/home/rakhil/go/src/github.com/ibmdb/go_ibm_db/api/zapi_unix.go:26 +0x59
github.com/ibmdb/go_ibm_db.(*BufferLen).Bind(0xc00005a3d8, 0x10001, 0x0, 0x440004, 0xc00005a3f8, 0x4, 0x8, 0xc000010350)
/home/rakhil/go/src/github.com/ibmdb/go_ibm_db/column.go:29 +0x62
github.com/ibmdb/go_ibm_db.(*BindableColumn).Bind(0xc00005a3c0, 0x10001, 0x0, 0xc00005a3c0, 0x0, 0x0)
/home/rakhil/go/src/github.com/ibmdb/go_ibm_db/column.go:202 +0x6c
github.com/ibmdb/go_ibm_db.(*ODBCStmt).BindColumns(0xc000092140, 0x7d9de0, 0x0)
/home/rakhil/go/src/github.com/ibmdb/go_ibm_db/odbcstmt.go:148 +0x1eb
github.com/ibmdb/go_ibm_db.(*Stmt).Query(0xc00007e2d0, 0x7d9de0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/home/rakhil/go/src/github.com/ibmdb/go_ibm_db/stmt.go:93 +0xe5
database/sql.ctxDriverStmtQuery(0x513040, 0xc000016138, 0x513140, 0xc00007e2d0, 0x7d9de0, 0x0, 0x0, 0x0, 0x0, 0x0, …)
/work/rakhil/go/src/database/sql/ctxutil.go:94 +0x16b
database/sql.rowsiFromStatement(0x513040, 0xc000016138, 0x512f40, 0xc000010290, 0xc00005a240, 0x0, 0x0, 0x0, 0x0, 0x0, …)
/work/rakhil/go/src/database/sql/sql.go:2511 +0x159
database/sql.(*Stmt).QueryContext(0xc0000a6000, 0x513040, 0xc000016138, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/work/rakhil/go/src/database/sql/sql.go:2463 +0x203
database/sql.(*Stmt).QueryRowContext(0xc0000a6000, 0x513040, 0xc000016138, 0x0, 0x0, 0x0, 0xc000016218)
/work/rakhil/go/src/database/sql/sql.go:2521 +0x6d
database/sql.(*Stmt).QueryRow(0xc0000a6000, 0x0, 0x0, 0x0, 0x0)
/work/rakhil/go/src/database/sql/sql.go:2540 +0x61
main.main.func1(0xc00001c2a0, 0xc0000a6000, 0xc0000a6090)
/home/rakhil/go/src/github.com/bradfitz/go-sql-test/src/sqltest/akh.go:49 +0xb4
created by main.main
/home/rakhil/go/src/github.com/bradfitz/go-sql-test/src/sqltest/akh.go:43 +0x472
exit status 2
THANKS IN ADVANCE.