Comments (6)
Please provide the complete example, especially how the table is created and queried - thanks!
from go-hdb.
Sure! This is a test code:
package main
import (
"bytes"
"database/sql"
"fmt"
"log"
"net/url"
"strings"
"github.com/SAP/go-hdb/driver"
)
func main() {
// create dsn
dsn := fmt.Sprintf("hdb://%s:%s@%s:%d", "username", "password", "host", 39013)
// open db
db, err := sql.Open("hdb", dsn)
if err != nil {
log.Fatal(err)
}
err = db.Ping()
if err != nil {
log.Fatal(err)
}
defer db.Close()
// drop table if exists
db.Exec(`drop table issue41`)
// drop table at end for cleaning
defer db.Exec(`drop table issue41`)
// create the table
_, err = db.Exec(`create table issue41 (a BLOB, b TEXT)`)
if err != nil {
log.Print(err)
return
}
// select column types
rows, err := db.Query(`select * from issue41`)
// the types are BLOB and NCLOB, supported like specified in lobexample_test.go
types, _ := rows.ColumnTypes()
for _, v := range types {
log.Printf("%s", v.DatabaseTypeName())
}
// begin transaction
tx, err := db.Begin()
// for BLOB column
// stmt, err := tx.Prepare("insert into issue41 (a) values (?)")
// for TEXT column (this is causing error)
stmt, err := tx.Prepare("insert into issue41 (b) values (?)")
if err != nil {
log.Print(err)
return
}
defer stmt.Close()
// create a lob reader for database writing
lob := new(driver.Lob)
r := bytes.NewReader([]byte("0123456789"))
lob.SetReader(r)
// insert the lob, here is returning the error for TEXT and BINTEXT column. Both returned with type NCLOB
_, err = stmt.Exec(lob)
if err != nil {
log.Print(err)
return
}
// commit transaction
err = tx.Commit()
if err != nil {
log.Print(err)
return
}
// print success
log.Print("success")
}
from go-hdb.
Update with result driver v0.99.1
Whit this driver version, TEXT is returned with datatype TEXT
and BINTEXT like NCLOB
The same code but different error output:
Inserting in a TEXT column: SQL Error 1033 - error while parsing protocol: no such data type: type_code=51, index=22
inserting in BINTEXT column:
panic: Missing FieldType for typeCode tcBlocator
goroutine 5 [running]:
github.com/SAP/go-hdb/internal/protocol.typeCode.fieldType(...)
C:/Users/sdelacruz/Documents/go/pkg/mod/github.com/!s!a!p/[email protected]/internal/protocol/typecode.go:217
github.com/SAP/go-hdb/internal/protocol.(*parameterField).Converter(0xc0000044c0, 0xcfbb00, 0xc00004ce10)
C:/Users/sdelacruz/Documents/go/pkg/mod/github.com/!s!a!p/[email protected]/internal/protocol/parameter.go:102 +0x142
github.com/SAP/go-hdb/driver.convertNamedValue(0xc00002c080, 0xc000017848, 0x0, 0x0)
C:/Users/sdelacruz/Documents/go/pkg/mod/github.com/!s!a!p/[email protected]/driver/convert.go:34 +0x7f
github.com/SAP/go-hdb/driver.(*stmt).CheckNamedValue(0xc0000580a0, 0xc000017848, 0x0, 0x0)
C:/Users/sdelacruz/Documents/go/pkg/mod/github.com/!s!a!p/[email protected]/driver/connection.go:531 +0x83
database/sql.driverArgsConnLocked(0xf24560, 0xc00004cd10, 0xc00002c0c0, 0xc000434000, 0x16, 0x16, 0xc0006860b0, 0x0, 0x0, 0xc0000ee0f0, ...)
C:/Users/sdelacruz/sdk/go1.14.2/src/database/sql/convert.go:177 +0x19b
database/sql.resultFromStatement(0xf26fe0, 0xc0000a0110, 0xf24560, 0xc00004cd10, 0xc00002c0c0, 0xc000434000, 0x16, 0x16, 0x0, 0x0, ...)
C:/Users/sdelacruz/sdk/go1.14.2/src/database/sql/sql.go:2430 +0xe6
database/sql.(*Stmt).ExecContext(0xc0000ee090, 0xf26fe0, 0xc0000a0110, 0xc000434000, 0x16, 0x16, 0x0, 0x0, 0x0, 0x0)
C:/Users/sdelacruz/sdk/go1.14.2/src/database/sql/sql.go:2411 +0x20a
database/sql.(*Stmt).Exec(...)
C:/Users/sdelacruz/sdk/go1.14.2/src/database/sql/sql.go:2423
.....
from go-hdb.
yes - the bug is not fixed yet - looks like an issue in the protocol layer - need to do some more testing to isolate the issue.
Thanks for re-testing!
from go-hdb.
Should be fixed with v0.100.4.
Best regards
from go-hdb.
Testing with v0.100.5, the same code above works when column b
is TEXT
, but panic when is BINTEXT
panic: Missing FieldType for typeCode tcLocator
goroutine 1 [running]:
github.com/SAP/go-hdb/internal/protocol.typeCode.fieldType(...)
C:/Users/sdelacruz/Documents/go/pkg/mod/github.com/!s!a!p/[email protected]/internal/protocol/typecode.go:214
github.com/SAP/go-hdb/internal/protocol.(*parameterField).Converter(0xc000004fc0, 0xc00007daa0, 0x40997c)
C:/Users/sdelacruz/Documents/go/pkg/mod/github.com/!s!a!p/[email protected]/internal/protocol/parameter.go:102 +0x142
github.com/SAP/go-hdb/driver.convertNamedValue(0xc00001e440, 0xc00006d320, 0xb85308, 0x38)
C:/Users/sdelacruz/Documents/go/pkg/mod/github.com/!s!a!p/[email protected]/driver/convert.go:34 +0x7f
github.com/SAP/go-hdb/driver.(*stmt).CheckNamedValue(0xc00004a550, 0xc00006d320, 0x1c0101, 0x0)
C:/Users/sdelacruz/Documents/go/pkg/mod/github.com/!s!a!p/[email protected]/driver/connection.go:531 +0x83
database/sql.driverArgsConnLocked(0x70a320, 0xc00003ea80, 0xc00001e480, 0xc00007de98, 0x1, 0x1, 0xc00003eb80, 0x0, 0x0, 0xc0001080f0, ...)
C:/Users/sdelacruz/sdk/go1.14.2/src/database/sql/convert.go:177 +0x19b
database/sql.resultFromStatement(0x70b3e0, 0xc000012018, 0x70a320, 0xc00003ea80, 0xc00001e480, 0xc00007de98, 0x1, 0x1, 0x0, 0x0, ...)
C:/Users/sdelacruz/sdk/go1.14.2/src/database/sql/sql.go:2430 +0xe6
database/sql.(*Stmt).ExecContext(0xc000108090, 0x70b3e0, 0xc000012018, 0xc00007de98, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0)
C:/Users/sdelacruz/sdk/go1.14.2/src/database/sql/sql.go:2411 +0x20a
database/sql.(*Stmt).Exec(...)
C:/Users/sdelacruz/sdk/go1.14.2/src/database/sql/sql.go:2423
main.issue41()
from go-hdb.
Related Issues (20)
- [Feature Request] Distribution settings hardcoded to OFF? HOT 8
- comments at the beginning of the query throws error HOT 9
- Bug - wrong scan type for decimal with null values HOT 6
- protocol error: invalid number of lob parameter ids 1 HOT 4
- [defect] insert lob with size more or equal to 8192 will fail HOT 1
- rows.Next does not stream all rows HOT 2
- Unable to open database connection due to DSN parsing error HOT 1
- dial tcp: missing address HOT 1
- goroutine leak detected in the driver package: callConverter HOT 1
- goroutine leak in driver package: init() HOT 2
- Does go-hdb support IP as the 'endpoint' of hana cloud connection? HOT 3
- Connection via hdbuserstore key does not work? HOT 1
- Connecting to Hana Cloud instance from local system gives connection error HOT 1
- Switch go.mod version to Go 1.21.0 HOT 2
- Consider going back to `go 1.21` in go.mod directive HOT 2
- Why adding options to flag in an embedded library? HOT 1
- ld: symbol(s) not found for architecture arm64 HOT 1
- Example code result error
- Support for `databaseName` query param HOT 1
- EOF error when using x509 certificate for login on HANA Cloud HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-hdb.