MCPcopy
hub / github.com/go-gorp/gorp / InsertQueryToTarget

Method InsertQueryToTarget

dialect_oracle.go:95–115  ·  view source on GitHub ↗

After executing the insert uses the ColMap IdQuery to get the generated id

(exec SqlExecutor, insertSql, idSql string, target interface{}, params ...interface{})

Source from the content-addressed store, hash-verified

93
94// After executing the insert uses the ColMap IdQuery to get the generated id
95func (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
117func (d OracleDialect) QuoteField(f string) string {
118 return `"` + strings.ToUpper(f) + `"`

Callers

nothing calls this directly

Calls 2

ExecMethod · 0.65
SelectIntMethod · 0.65

Tested by

no test coverage detected