Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

affected/package: database/sql "Deficiency in the code" #56618

Closed
xarick opened this issue Nov 7, 2022 · 2 comments
Closed

affected/package: database/sql "Deficiency in the code" #56618

xarick opened this issue Nov 7, 2022 · 2 comments

Comments

@xarick
Copy link

xarick commented Nov 7, 2022

go version: go 1.19

my problem is with the database/sql package. I have plsql code available in service. values are sent to the service via map. but the number is not limited,

I need to send to db.exec() via sql.Named, I checked with loop and with interface, it didn't work.

Please help me.

my codes are:

in the controller

	const begin = `
		jsonData.Put('stateid', :stateid);
	`

       array_for_param := map[string]string{
		"stateid": "a",
	}

	temp, err := services.Perform(c, begin, array_for_param, i_User_Id)

	if err != nil {
		log.Fatal(err)
	}

service code:

	var params []interface{}

	for key, value := range array_for_param {
		params = append(params, sql.Named(key, value))
	}

	if _, err := db.Exec(declare+begin+end,
		sql.Named("i_User_Id", i_User_Id),
		params...,
	); err != nil {
		log.Fatal(err)
	}
	); err != nil {
		log.Fatal(err)
	}

The main problem I have is that I need to send the sql.Named code using a for, which is an unknown number

@xarick
Copy link
Author

xarick commented Nov 7, 2022

	if _, err := db.Exec(declare+begin+end,
		sql.Named("i_User_Id", i_User_Id),
		for key, value := range array_for_param {
			return sql.Named(key, value)
		}
	); err != nil {
		log.Fatal(err)
	}

I did that too

@seankhliao
Copy link
Member

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Nov 7, 2022
@golang golang locked and limited conversation to collaborators Nov 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants