-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfloat32.go
More file actions
51 lines (43 loc) · 1.05 KB
/
float32.go
File metadata and controls
51 lines (43 loc) · 1.05 KB
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
package odbc
import (
"database/sql/driver"
"github.com/ninthclowd/unixodbc/internal/api"
"reflect"
"unsafe"
)
func init() {
registerColumnFactoryForType(newFloat32Column, api.SQL_REAL)
}
func newFloat32Column(info *columnInfo, hnd *handle) Column {
return &columnFloat32{hnd, info}
}
type columnFloat32 struct {
*handle
*columnInfo
}
func (c *columnFloat32) VariableLength() (length int64, ok bool) {
return
}
func (c *columnFloat32) ScanType() reflect.Type {
return reflect.TypeOf((*float32)(nil))
}
func (c *columnFloat32) Decimal() (precision int64, scale int64, ok bool) {
return int64(c.columnSize), int64(c.decimalDigits), true
}
//go:nocheckptr
func (c *columnFloat32) Value() (driver.Value, error) {
var value api.SQLREAL
var valueLength api.SQLLEN
if _, err := c.result(api.SQLGetData((*api.SQLHSTMT)(c.hnd()),
c.columnNumber,
api.SQL_C_FLOAT,
(*api.SQLPOINTER)(unsafe.Pointer(&value)),
0,
&valueLength)); err != nil {
return nil, err
}
if valueLength == api.SQL_NULL_DATA {
return nil, nil
}
return float32(value), nil
}