Skip to content

Commit

Permalink
fix rowid issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn committed Aug 8, 2016
1 parent 60511e9 commit daa0a9b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion _example/lastinsertid/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,12 @@ func main() {
fmt.Println(err)
return
}
println(oci8.GetLastInsertId(lastInsertId))
rowID := oci8.GetLastInsertId(lastInsertId)
var id string
err = db.QueryRow("select id from lastinsertid_example where rowid = :1", rowID).Scan(&id)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(id)
}
4 changes: 2 additions & 2 deletions oci8.go
Original file line number Diff line number Diff line change
Expand Up @@ -1117,8 +1117,8 @@ func (s *OCI8Stmt) Query(args []driver.Value) (rows driver.Rows, err error) {
func (s *OCI8Stmt) lastInsertId() (int64, error) {
retRowid := C.WrapOCIAttrRowId(s.c.env, s.s, C.OCI_HTYPE_STMT, C.OCI_ATTR_ROWID, (*C.OCIError)(s.c.err))
if retRowid.rv == C.OCI_SUCCESS {
bs := make([]byte, 19)
for i, b := range retRowid.rowid {
bs := make([]byte, 18)
for i, b := range retRowid.rowid[:18] {
bs[i] = byte(b)
}
rowid := string(bs)
Expand Down

0 comments on commit daa0a9b

Please sign in to comment.