forked from mattn/go-oci8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oci8_go18.go
59 lines (51 loc) · 1.49 KB
/
oci8_go18.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package oci8
import (
"database/sql"
"database/sql/driver"
"context"
)
func toNamedValue(nv driver.NamedValue) namedValue {
mv := namedValue(nv)
return mv
}
// QueryContext implement QueryerContext.
func (conn *OCI8Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) {
list := make([]namedValue, len(args))
for i, nv := range args {
list[i] = toNamedValue(nv)
}
return conn.query(ctx, query, list)
}
// ExecContext implement ExecerContext.
func (conn *OCI8Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) {
list := make([]namedValue, len(args))
for i, nv := range args {
list[i] = toNamedValue(nv)
}
return conn.exec(ctx, query, list)
}
// QueryContext implement QueryerContext.
func (stmt *OCI8Stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) {
list := make([]namedValue, len(args))
for i, nv := range args {
list[i] = toNamedValue(nv)
}
return stmt.query(ctx, list, false)
}
// ExecContext implement ExecerContext.
func (stmt *OCI8Stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) {
list := make([]namedValue, len(args))
for i, nv := range args {
list[i] = toNamedValue(nv)
}
return stmt.exec(ctx, list)
}
// CheckNamedValue checks the named value
func (conn *OCI8Conn) CheckNamedValue(nv *driver.NamedValue) error {
switch nv.Value.(type) {
default:
return driver.ErrSkip
case sql.Out:
return nil
}
}