You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to prepare multiple value query, something like :
INSERT INTO my_table (column1, column2) VALUES
(?, ?),
(?, ?);
To do that I did :
theQuery:="INSERT INTO my_table (column1, column2) VALUES \n"vals:= []interface{}{}
for_, a:=rangearray.Array {
theQuery+="(?, ?),\n"vals=append(vals, a.value1, a.Value2)
}
//trim the last ,theQuery=strings.TrimSuffix(theQuery, ",\n") +";"//prepare the statementstmt, err:=db.Prepare(theQuery) // error hereiferr!=nil {
returnerr
}
deferstmt.Close()
//format all vals at onceres, err:=stmt.Exec(vals...)
iferr!=nil {
returnerr
}
What did you expect to see?
No error
What did you see instead?
error is return on stmt, err := db.Prepare(theQuery)
saying : syntax error at or near ","
Questions ?
I started to dev in go some month ago, I tried to search on google/stackoverflow for some example
without any luck, so I am here, trying to know if it is the database/sql driver that doesnt support this kind of prepare or it is me failing
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?1.9
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?What did you do?
With the driver :
database/sql
I want to prepare multiple value query, something like :
To do that I did :
What did you expect to see?
No error
What did you see instead?
error is return on
stmt, err := db.Prepare(theQuery)
saying :
syntax error at or near ","
Questions ?
I started to dev in go some month ago, I tried to search on google/stackoverflow for some example
without any luck, so I am here, trying to know if it is the
database/sql driver
that doesnt support this kind of prepare or it is me failingThe text was updated successfully, but these errors were encountered: