Giter VIP home page Giter VIP logo

Comments (2)

sijms avatar sijms commented on August 27, 2024

code:

package main

import (
	"database/sql"
	"fmt"
	go_ora "github.com/sijms/go-ora/v2"
	"os"
	"time"
)

func exec(db *sql.DB) error {
	t := time.Now()
	sqlText := `BEGIN
	SELECT 'a', 'b' into :aVar, :bVar FROM DUAL;
	END;`
	var aVar, bVar string
	_, err := db.Exec(sqlText, sql.Named("bVar", go_ora.Out{Dest: &bVar, Size: 5}),
		sql.Named("aVar", go_ora.Out{Dest: &aVar, Size: 5}))
	if err != nil {
		return err
	}
	fmt.Println("aVar: ", aVar, "\tbVar: ", bVar)
	fmt.Println("finish exec: ", time.Now().Sub(t))
	return nil
}
func main() {
	db, err := sql.Open("oracle", os.Getenv("DSN"))
	if err != nil {
		fmt.Println("can't connect: ", err)
		return
	}
	defer func() {
		err = db.Close()
		if err != nil {
			fmt.Println("can't close connection: ", err)
		}
	}()
	err = exec(db)
	if err != nil {
		fmt.Println("can't exec: ", err)
		return
	}

}

result:

aVar:  a        bVar:  b
finish exec:  1.286287703s

from go-ora.

CharliePlate avatar CharliePlate commented on August 27, 2024

Thank you for the quick response.

It seems my project was using an old version, which seeing your response prompted me to double check. After updating, this is working as intended. Thank you for testing with me and apologies for my ignorance.

from go-ora.

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.