Using PHP sql pdo driver i can send multiple statements into a single query and get multiple row sets.
$sql = "insert into foo () values () ; insert into bar () values (), ()";
$stmt = $dbh->prepare($sql);
$stmt->execute();
do {
echo "row count: ".$stmt->rowCount()."\n";
} while ($stmt->nextRowset());
I am looking forward to achieve the same thing in Go.
I've tried below snippet to update a table. But when printing res.Next()
and res.NextResultSet()
, both are false
while the rows are updated after my checking. So I cannot iterate the resultset to get the count.
tx, _ := conn.StartTransaction(ctx)
sqlstr := `update table1 set user_name = "d1" where user_id = 1;
update table1 set user_name = "d2" where user_id = 2;`
res, err := tx.Query(sqlstr)
if err != nil {
fmt.Println(err.Error())
}
fmt.Println(res.Next())
fmt.Println(res.NextResultSet())