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
+11.7k Golang : How to detect a server/machine network interface capabilities?
+15k Golang : package is not in GOROOT during compilation
+17.1k Golang : Capture stdout of a child process and act according to the result
+19.8k Golang : Append content to a file
+17.8k Golang : Iterate linked list example
+7.5k Golang : Detect sample rate, channels or latency with PortAudio
+13.7k Golang : Tutorial on loading GOB and PEM files
+8k Golang : What fmt.Println() can do and println() cannot do
+8.2k Golang : Routes multiplexer routing example with regular expression control
+22.8k Golang : untar or extract tar ball archive example