GithubHelp home page GithubHelp logo

Comments (8)

stfnmllr avatar stfnmllr commented on July 21, 2024 1

The example should work with v0.100.7 although full test of BINTEXT is not yet finalized.

from go-hdb.

stfnmllr avatar stfnmllr commented on July 21, 2024

Did make it work (v0.100.6), so that the example you shared is giving results. Anyway, need to provide some tests to be sure that the Bintext support is completely implemented.
Please share your findings in further tests as well. I'll leave the ticket open for the time being.
Thanks and best regards

from go-hdb.

xhit avatar xhit commented on July 21, 2024

Tested v0.100.6

Inserting values when there are at least 2 lob columns insert (BLOB, TEXT, BINTEXT) and one is BINTEXT then this error is returned:

protocol error: invalid number of lob parameter ids 1 - expected 2

Example code:

package main

import (
	"bytes"
	"database/sql"
	"fmt"
	"log"

	"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.Print(err)
		return
	}

	err = db.Ping()
	if err != nil {
		log.Print(err)
		return
	}

	defer db.Close()

	// drop table if exists
	db.Exec(`drop table issue50`)

	// drop table at end for cleaning
	defer db.Exec(`drop table issue50`)

	// create the table
	_, err = db.Exec(`create table issue50 (a BLOB, b BINTEXT)`)
	if err != nil {
		log.Print(err)
		return
	}

	// select column types
	rows, err := db.Query(`select * from issue50`)
         if err != nil {
		log.Print(err)
		return
	}

	types, _ := rows.ColumnTypes()
	for _, v := range types {
		log.Printf("%s", v.DatabaseTypeName())
	}

	// begin transaction
	tx, err := db.Begin()

	stmt, err := tx.Prepare("insert into issue50 (a,b) values (?,?)")
	if err != nil {
		log.Print(err)
		return
	}

	defer stmt.Close()

	// create a lob reader for BLOB
	lobBLOB := new(driver.Lob)
	r := bytes.NewReader([]byte("0123456789"))
	lobBLOB.SetReader(r)

	// create a lob reader for BINTEXT
	lobBINTEXT := new(driver.Lob)
	r1 := bytes.NewReader([]byte("0123456789"))
	lobBINTEXT.SetReader(r1)

	_, err = stmt.Exec(lobBLOB, lobBINTEXT)
	if err != nil {
		log.Print(err)
		return
	}

	// commit transaction
	err = tx.Commit()
	if err != nil {
		log.Print(err)
		return
	}

	// print success
	log.Print("success")
}

This should be another issue because this was completed, but I think you said this issue will be open while BINTEXT is in alpha.

from go-hdb.

stfnmllr avatar stfnmllr commented on July 21, 2024

Thanks for testing!

This should be another issue because this was completed, but I think you said this issue will be
open while BINTEXT is in alpha.

Yes, that's fine - let's use this ticket until all issues with BINTEXT are ironed out.
Best regards

from go-hdb.

xhit avatar xhit commented on July 21, 2024

Works.

For now the v0.100.7 works like expected in my tests. I will test all other new releases to check until BINTEXT is completed.

Thanks.

from go-hdb.

stfnmllr avatar stfnmllr commented on July 21, 2024

Thanks for your testing effort and confirming on the bug resolution.

from go-hdb.

xhit avatar xhit commented on July 21, 2024

Tested v0.100.10. Works.

from go-hdb.

xhit avatar xhit commented on July 21, 2024

Tested v0.102.2. Works.

from go-hdb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.