Golang database/sql.Result type example
package database/sql
A Result summarizes an executed SQL command.
Golang database/sql.Result type usage example
stmt, err := db.Prepare("INSERT INTO users(name) VALUES(?)")
if err != nil {
log.Fatal(err)
}
result, err := stmt.Exec("superman") // <-- here
if err != nil {
log.Fatal(err)
}
lastId, err := result.LastInsertId()
if err != nil {
log.Fatal(err)
}
rowCnt, err := result.RowsAffected()
if err != nil {
log.Fatal(err)
}
Reference :
Advertisement
Something interesting
Tutorials
+8.1k Golang : Variadic function arguments sanity check example
+80.7k Golang : How to return HTTP status code?
+15.4k Golang : invalid character ',' looking for beginning of value
+13.5k Facebook PHP getUser() returns 0
+5.7k Linux/Unix/PHP : Restart PHP-FPM
+5.4k Golang : Get S3 or CloudFront object or file information
+5.2k JavaScript/JQuery : Redirect page examples
+9.6k Javascript : Read/parse JSON data from HTTP response
+13.5k Golang : How to get year, month and day?
+30k Golang : Get time.Duration in year, month, week or day
+5.3k Swift : Convert string array to array example
+17.6k Golang : Upload/Receive file progress indicator