本文整理汇总了Golang中database/sql.Rows.Sibling方法的典型用法代码示例。如果您正苦于以下问题:Golang Rows.Sibling方法的具体用法?Golang Rows.Sibling怎么用?Golang Rows.Sibling使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类database/sql.Rows
的用法示例。
在下文中一共展示了Rows.Sibling方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: validate_multi_second_select
func validate_multi_second_select(dbt *DBTest, rows *sql.Rows) {
if _, ok := rows.Sibling(); false == ok {
dbt.Fatal("rows should have a another sibling.")
}
if false == rows.Next() {
dbt.Fatalf("should be one row exists.\n")
}
if err := rows.Scan(&id, &fv, &id2); err != nil {
dbt.Fatalf("should not get error :%s\n", err.Error())
}
if 323890472 != id {
dbt.Fatalf("expect 323890472, but got %d\n", id)
}
if math.Abs(42342.43-float64(fv)) > 0.01 {
dbt.Fatalf("expect 42342.432, but not got %+v\n", fv)
}
if rows.Next() {
dbt.Fatal("rows should not have more than one row.")
}
if 298723987 != id2 {
dbt.Fatalf("expect 298723987, but got %d\n", id2)
}
}
示例2: validate_result_of_sp
func validate_result_of_sp(dbt *DBTest, rows *sql.Rows) {
// final OK packet , indicate last INSERT effected rows
// https://dev.mysql.com/doc/internals/en/multi-resultset.html
if res, ok := rows.Sibling(); false == ok {
dbt.Fatal("there should be a last ok packet.")
} else if nil == res {
dbt.Fatal("last packet of CALL should return a Result.")
} else {
if affcted, err := res.RowsAffected(); nil != err {
dbt.Fatal("should not return err when RowsAffected")
} else if 1 != affcted {
dbt.Fatal("Last INSERT STMT in SP should affected one row. ")
}
if insertId, err := res.LastInsertId(); nil != err {
dbt.Fatal("should not return err when LastInsertId")
} else if 0 != insertId {
dbt.Fatalf("Last INSERT STMT in SP should not return LAST_INSERT_ID:%d ", insertId)
}
if true == rows.Next() {
dbt.Fatal("last packet has no rows, but just affected rows and last insert id")
}
}
}