-
-
Notifications
You must be signed in to change notification settings - Fork 174
/
simple_object.go
95 lines (91 loc) · 2 KB
/
simple_object.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package go_ora
import (
"errors"
"fmt"
"github.com/sijms/go-ora/network"
)
type simpleObject struct {
connection *Connection
//session *network.Session
operationID uint8
data []byte
err error
}
func (obj *simpleObject) write() *simpleObject {
//obj.session.ResetBuffer()
if obj.connection.dBVersion.Number >= 10102 {
session := obj.connection.session
session.PutBytes(3, obj.operationID, 0)
if obj.data != nil {
session.PutBytes(obj.data...)
}
obj.err = session.Write()
}
return obj
}
func (obj *simpleObject) read() error {
if obj.connection.dBVersion.Number >= 10102 {
session := obj.connection.session
if obj.err != nil {
return obj.err
}
loop := true
for loop {
msg, err := session.GetByte()
if err != nil {
return err
}
switch msg {
case 4:
session.Summary, err = network.NewSummary(session)
if err != nil {
return err
}
loop = false
case 9:
if session.HasEOSCapability {
if session.Summary == nil {
session.Summary = new(network.SummaryObject)
}
session.Summary.EndOfCallStatus, err = session.GetInt(4, true, true)
if err != nil {
return err
}
}
if session.HasFSAPCapability {
if session.Summary == nil {
session.Summary = new(network.SummaryObject)
}
session.Summary.EndToEndECIDSequence, err = session.GetInt(2, true, true)
if err != nil {
return err
}
}
loop = false
case 15:
warning, err := network.NewWarningObject(session)
if err != nil {
return err
}
if warning != nil {
fmt.Println(warning)
}
case 23:
//opCode, err := session.GetByte()
//if err != nil {
// return err
//}
//err = obj.connection.getServerNetworkInformation(opCode)
//if err != nil {
// return err
//}
default:
return errors.New(fmt.Sprintf("TTC error: received code %d during simple object read", msg))
}
}
if session.HasError() {
return session.GetError()
}
}
return nil
}