我正在尝试使用golang和标准sql驱动程序在SQLite3数据库的单行中更新多个值,但是在调试以下错误时遇到问题:
command-line-arguments
./server.go:169: multiple-value updateStatement.Exec() in single-value context
相关代码如下(不相关的代码已被省略):
SQL语句:
const (
rsvpSubmit = "UPDATE rsvp SET Name = ?, Rsvp = ?, Guests = ?, Meal0 = ?, Meal1 = ?, Comments = ?, ModifiedAt = ? WHERE email = ?"
)
var (
updateStatement *sql.Stmt
)
errr := updateStatement.Exec(
r.FormValue("name"),
r.FormValue("rsvp"),
r.FormValue("guests"),
r.FormValue("meal0"),
r.FormValue("meal1"),
r.FormValue("comments"),
time.Now(),
cookie.Value)
数据库具有以下列(struct复制):
type User struct {
Id int
Email string
Name sql.NullString
Rsvp sql.NullInt64
Guests sql.NullInt64
Meal0 sql.NullString
Meal1 sql.NullString
Comments sql.NullString
ModifiedAt sql.NullString
}
非常感谢任何帮助!
答案 0 :(得分:3)
Stmt.Exec
定义为:
func (s *Stmt) Exec(args ...interface{}) (Result, error)
如果您不关心结果,那么您可以使用_, err := updateStatement.Exec(...)