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
+21.8k SSL : How to check if current certificate is sha1 or sha2
+41k Golang : How to check if a string contains another sub-string?
+5.4k Golang : Qt update UI elements with core.QCoreApplication_ProcessEvents
+9.2k Golang : Write multiple lines or divide string into multiple lines
+14k Golang : concatenate(combine) strings
+6.9k How to let Facebook Login button redirect to a particular URL ?
+15.2k Golang : Get timezone offset from date or timestamp
+9.6k Golang : How to generate Code 39 barcode?
+6.7k Golang : When to use make or new?
+12k Golang : Convert a rune to unicode style string \u
+25.9k Golang : How to read integer value from standard input ?
+8.5k Linux/Unix : fatal: the Postfix mail system is already running