After executing the insert uses the ColMap IdQuery to get the generated id
(exec SqlExecutor, insertSql, idSql string, target interface{}, params ...interface{})
| 93 | |
| 94 | // After executing the insert uses the ColMap IdQuery to get the generated id |
| 95 | func (d OracleDialect) InsertQueryToTarget(exec SqlExecutor, insertSql, idSql string, target interface{}, params ...interface{}) error { |
| 96 | _, err := exec.Exec(insertSql, params...) |
| 97 | if err != nil { |
| 98 | return err |
| 99 | } |
| 100 | id, err := exec.SelectInt(idSql) |
| 101 | if err != nil { |
| 102 | return err |
| 103 | } |
| 104 | switch target.(type) { |
| 105 | case *int64: |
| 106 | *(target.(*int64)) = id |
| 107 | case *int32: |
| 108 | *(target.(*int32)) = int32(id) |
| 109 | case int: |
| 110 | *(target.(*int)) = int(id) |
| 111 | default: |
| 112 | return fmt.Errorf("Id field can be int, int32 or int64") |
| 113 | } |
| 114 | return nil |
| 115 | } |
| 116 | |
| 117 | func (d OracleDialect) QuoteField(f string) string { |
| 118 | return `"` + strings.ToUpper(f) + `"` |