forked from mattn/go-oci8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oci8_go18.go
78 lines (66 loc) · 1.93 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// +build go1.8
package oci8
import (
"database/sql"
"database/sql/driver"
"context"
)
// Ping implement Pinger.
func (c *OCI8Conn) Ping(ctx context.Context) error {
return c.ping(ctx)
}
func toNamedValue(nv driver.NamedValue) namedValue {
mv := namedValue(nv)
if out, ok := mv.Value.(sql.Out); ok {
mv.Value = outValue{Dest: out.Dest, In: out.In}
}
return mv
}
// QueryContext implement QueryerContext.
func (c *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] = namedValue(nv)
}
return c.query(ctx, query, list)
}
// ExecContext implement ExecerContext.
func (c *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] = namedValue(nv)
}
return c.exec(ctx, query, list)
}
// PrepareContext implement ConnPrepareContext.
func (c *OCI8Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) {
return c.prepare(ctx, query)
}
// BeginTx implement ConnBeginTx.
func (c *OCI8Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
return c.begin(ctx)
}
// QueryContext implement QueryerContext.
func (s *OCI8Stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) {
list := make([]namedValue, len(args))
for i, nv := range args {
list[i] = namedValue(nv)
}
return s.query(ctx, list)
}
// ExecContext implement ExecerContext.
func (s *OCI8Stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) {
list := make([]namedValue, len(args))
for i, nv := range args {
list[i] = namedValue(nv)
}
return s.exec(ctx, list)
}
func (c *OCI8Conn) CheckNamedValue(nv *driver.NamedValue) error {
switch nv.Value.(type) {
default:
return driver.ErrSkip
case sql.Out:
return nil
}
}