func (def *defFloat32) value() (value interface{}, err error) { if def.isNullable { oraFloat32Value := Float32{IsNull: def.null < C.sb2(0)} if !oraFloat32Value.IsNull { var float32Value float32 r := C.OCINumberToReal( def.rset.stmt.ses.srv.env.ocierr, //OCIError *err, &def.ociNumber, //const OCINumber *number, C.uword(4), //uword rsl_length, unsafe.Pointer(&oraFloat32Value.Value)) //void *rsl ); if r == C.OCI_ERROR { err = def.rset.stmt.ses.srv.env.ociError() } value = float32Value } value = oraFloat32Value } else { if def.null > C.sb2(-1) { var float32Value float32 r := C.OCINumberToReal( def.rset.stmt.ses.srv.env.ocierr, //OCIError *err, &def.ociNumber, //const OCINumber *number, C.uword(4), //uword rsl_length, unsafe.Pointer(&float32Value)) //void *rsl ); if r == C.OCI_ERROR { err = def.rset.stmt.ses.srv.env.ociError() } value = float32Value } } return value, err }
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 }
// StartTx starts an Oracle transaction returning a *Tx and possible error. func (ses *Ses) StartTx() (tx *Tx, err error) { ses.mu.Lock() defer ses.mu.Unlock() ses.log(_drv.cfg.Log.Ses.StartTx) err = ses.checkClosed() if err != nil { return nil, errE(err) } // start transaction // the number of seconds the transaction can be inactive // before it is automatically terminated by the system. // TODO: add timeout config value var timeout C.uword = C.uword(60) r := C.OCITransStart( ses.srv.ocisvcctx, //OCISvcCtx *svchp, ses.srv.env.ocierr, //OCIError *errhp, timeout, //uword timeout, C.OCI_TRANS_NEW) //ub4 flags ); if r == C.OCI_ERROR { return nil, errE(ses.srv.env.ociError()) } tx = _drv.txPool.Get().(*Tx) // set *Tx tx.ses = ses if tx.id == 0 { tx.id = _drv.txId.nextId() } ses.openTxs.add(tx) return tx, nil }
func (env *Environment) numberFromInt(value int64, dst unsafe.Pointer) error { return env.CheckStatus( C.OCINumberFromInt(env.errorHandle, unsafe.Pointer(&value), C.uword(unsafe.Sizeof(value)), C.OCI_NUMBER_SIGNED, (*C.OCINumber)(dst)), "numberFromInt") }
func (bnd *bndFloat64Ptr) setPtr() error { if bnd.isNull > C.sb2(-1) { r := C.OCINumberToReal( bnd.stmt.ses.srv.env.ocierr, //OCIError *err, &bnd.ociNumber, //const OCINumber *number, C.uword(8), //uword rsl_length, unsafe.Pointer(bnd.value)) //void *rsl ); if r == C.OCI_ERROR { return bnd.stmt.ses.srv.env.ociError() } } return nil }
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 }
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 }
func (env *Environment) numberFromFloat(value float64, dst unsafe.Pointer) error { return env.CheckStatus( C.OCINumberFromReal(env.errorHandle, unsafe.Pointer(&value), C.uword(unsafe.Sizeof(value)), (*C.OCINumber)(dst)), "numberFromReal") }