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

PreparedStatement.Exec do not work with in #767

Closed
SummerBuger opened this issue Mar 11, 2018 · 1 comment
Closed

PreparedStatement.Exec do not work with in #767

SummerBuger opened this issue Mar 11, 2018 · 1 comment

Comments

@SummerBuger
Copy link

SummerBuger commented Mar 11, 2018

Using prepared statement exec delete from xxx where id in (....) do not work

Using prepared statement exec delete from xxx where id in (?, ?, ?, ?...) do not work, but after I change the code to delete form xxx where id = ?, and invoke the sql again and again, the prepared statement work successed.

The failed code

paramArr := []int{1,2,3}
tx,_ := performanceDb.Begin();
stmt,_ := tx.Prepare('delete from xxx where id in (?,?,?)')
 result, _ := stmt.Exec(paramArr...)
affectedRowSize, _ := result.RowsAffected() // the affectedRowSize always be 0!!!

The successed code

paramArr := []int{1,2,3}
tx,_ := performanceDb.Begin();
stmt,_ := tx.Prepare('delete from xxx where id = ?')
for _, p := range paramArr {
     result, _ := stmt.Exec(p)  // the delete sql will successed!
}

Error log

There is no error log!!!

Configuration

Go version: go version go1.9.2 darwin/amd64

Server version: 5.6.24-log MySQL Community Server (GPL)

Running Server OS: Linux e93f19544.em21 2.6.32-358.23.2.ali1195.el6.x86_64 #1 SMP Wed Oct 29 20:23:37 CST 2014 x86_64 x86_64 x86_64 GNU/Linux

Building Server OS: Darwin localhost 16.3.0 Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64 x86_64

@methane
Copy link
Member

methane commented Mar 12, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants