I have this:
tx, _ := db.Begin()
p := person.Person{Handle: "foo"}
rows, err := tx.Exec("INSERT INTO person (handle, email) VALUES ($1, $2) RETURNING id", p.Handle, p.Email).
notice how it says RETURNING id
in the sql query..how can I get the id from the first row return by the query?
I tried this:
var id string
defer rows.Close()
for rows.Next() {
err := rows.Scan(&id, &name)
if err != nil {
log.Fatal(err)
}
log.Println(id, name)
}
but I get this compile error:
rows.Close undefined (type sql.Result has no field or method Close)