作者:optimus
项目:or
func (def *defUint64) value() (value interface{}, err error) {
if def.isNullable {
oraUint64Value := Uint64{IsNull: def.null < C.sb2(0)}
if !oraUint64Value.IsNull {
r := C.OCINumberToInt(
def.rset.stmt.ses.srv.env.ocierr, //OCIError *err,
&def.ociNumber, //const OCINumber *number,
C.uword(8), //uword rsl_length,
C.OCI_NUMBER_UNSIGNED, //uword rsl_flag,
unsafe.Pointer(&oraUint64Value.Value)) //void *rsl );
if r == C.OCI_ERROR {
err = def.rset.stmt.ses.srv.env.ociError()
}
}
value = oraUint64Value
} else {
if def.null > C.sb2(-1) {
var uint64Value uint64
r := C.OCINumberToInt(
def.rset.stmt.ses.srv.env.ocierr, //OCIError *err,
&def.ociNumber, //const OCINumber *number,
C.uword(8), //uword rsl_length,
C.OCI_NUMBER_UNSIGNED, //uword rsl_flag,
unsafe.Pointer(&uint64Value)) //void *rsl );
if r == C.OCI_ERROR {
err = def.rset.stmt.ses.srv.env.ociError()
}
value = uint64Value
}
}
return value, err
}
作者:salahwadi
项目:goracl
func numAsInt(v *Variable, num *C.OCINumber) (intVal int32, err error) {
if err = v.environment.CheckStatus(
C.OCINumberToInt(v.environment.errorHandle,
//(*C.OCINumber)(v.getHandle(pos)),
num,
4, C.OCI_NUMBER_SIGNED, unsafe.Pointer(&intVal)),
"numberToInt"); err != nil {
return -1, errgo.Mask(err)
}
return
}
作者:ricsmani
项目:or
func (bnd *bndUint16Ptr) setPtr() error {
if bnd.isNull > C.sb2(-1) {
r := C.OCINumberToInt(
bnd.stmt.ses.srv.env.ocierr, //OCIError *err,
&bnd.ociNumber, //const OCINumber *number,
C.uword(2), //uword rsl_length,
C.OCI_NUMBER_UNSIGNED, //uword rsl_flag,
unsafe.Pointer(bnd.value)) //void *rsl );
if r == C.OCI_ERROR {
return bnd.stmt.ses.srv.env.ociError()
}
}
return nil
}
作者:ricsmani
项目:or
func (bnd *bndInt32Ptr) setPtr() error {
if bnd.isNull > C.sb2(-1) {
r := C.OCINumberToInt(
bnd.stmt.ses.srv.env.ocierr, //OCIError *err,
&bnd.ociNumber, //const OCINumber *number,
C.uword(4), //uword rsl_length,
C.OCI_NUMBER_SIGNED, //uword rsl_flag,
unsafe.Pointer(bnd.value)) //void *rsl );
if r == C.OCI_ERROR {
return bnd.stmt.ses.srv.env.ociError()
}
bnd.stmt.logF(_drv.cfg.Log.Stmt.Bind,
"Int32Ptr.setPtr number=%#v => value=%d", bnd.ociNumber, *bnd.value)
}
return nil
}
作者:rjammal
项目:goracl
// Returns the value stored at the given array position.
func numberVarGetValue(v *Variable, pos uint) (interface{}, error) {
if v.dataFloats != nil {
// log.Printf("getting pos=%d from %+v", pos, v.dataFloats)
return v.dataFloats[pos], nil
}
if v.dataInts != nil {
// log.Printf("getting pos=%d from %+v", pos, v.dataInts)
return v.dataInts[pos], nil
}
if v.typ == NumberAsStringVarType {
buf := make([]byte, 200)
var size C.ub4
if err := v.environment.CheckStatus(
C.OCINumberToText(v.environment.errorHandle,
(*C.OCINumber)(v.getHandle(pos)),
(*C.oratext)(unsafe.Pointer(&v.environment.numberToStringFormatBuffer[0])),
C.ub4(len(v.environment.numberToStringFormatBuffer)), nil, 0,
&size, (*C.oratext)(&buf[0])),
"NumberToText"); err != nil {
return 0, err
}
return v.environment.FromEncodedString(buf[:int(size)]), nil
}
// log.Printf("v=%s IsInteger?%s", v.typ, v.typ.IsInteger())
if v.typ.IsInteger() {
intVal := int64(0)
if err := v.environment.CheckStatus(
C.OCINumberToInt(v.environment.errorHandle,
(*C.OCINumber)(v.getHandle(pos)),
C.sizeof_long, C.OCI_NUMBER_SIGNED, unsafe.Pointer(&intVal)),
"numberToInt"); err != nil {
return -1, err
}
if v.typ == BooleanVarType {
return intVal > 0, nil
}
return intVal, nil
}
floatVal := float64(0)
err := v.environment.CheckStatus(
C.OCINumberToReal(v.environment.errorHandle,
(*C.OCINumber)(v.getHandle(pos)),
C.sizeof_double, unsafe.Pointer(&floatVal)),
"numberToFloat")
return floatVal, err
}