コード例 #1
0
ファイル: defIntervalDS.go プロジェクト: optimuse/ora
func (def *defIntervalDS) value() (value interface{}, err error) {
	intervalDS := IntervalDS{IsNull: def.null < C.sb2(0)}
	if !intervalDS.IsNull {
		var day C.sb4
		var hour C.sb4
		var minute C.sb4
		var second C.sb4
		var nanosecond C.sb4
		r := C.OCIIntervalGetDaySecond(
			unsafe.Pointer(def.rset.stmt.ses.srv.env.ocienv), //void               *hndl,
			def.rset.stmt.ses.srv.env.ocierr,                 //OCIError           *err,
			&day,            //sb4                *dy,
			&hour,           //sb4                *hr,
			&minute,         //sb4                *mm,
			&second,         //sb4                *ss,
			&nanosecond,     //sb4                *fsec,
			def.ociInterval) //const OCIInterval  *interval );
		if r == C.OCI_ERROR {
			err = def.rset.stmt.ses.srv.env.ociError()
		}
		intervalDS.Day = int32(day)
		intervalDS.Hour = int32(hour)
		intervalDS.Minute = int32(minute)
		intervalDS.Second = int32(second)
		intervalDS.Nanosecond = int32(nanosecond)
	}
	return intervalDS, err
}
コード例 #2
0
ファイル: datetimevar.go プロジェクト: viney/go-db-driver
// Returns the value stored at the given array position.
func internalVar_GetValue(v *Variable, pos uint) (interface{}, error) {
	var days, hours, minutes, seconds, microseconds C.sb4

	if err := v.environment.CheckStatus(
		C.OCIIntervalGetDaySecond(unsafe.Pointer(v.environment.handle),
			v.environment.errorHandle,
			&days, &hours, &minutes, &seconds, &microseconds,
			(*C.OCIInterval)(unsafe.Pointer((&v.dataBytes[pos*v.typ.size])))),
		"internalVar_GetValue"); err != nil {
		return nil, err
	}
	return (time.Duration(days)*24*time.Hour +
		time.Duration(hours)*time.Hour +
		time.Duration(minutes)*time.Minute +
		time.Duration(seconds)*time.Second +
		time.Duration(microseconds)*time.Microsecond), nil
}
コード例 #3
0
ファイル: datetimevar.go プロジェクト: tgulacsi/go-sql-test
// Returns the value stored at the given array position.
func intervalVarGetValue(v *Variable, pos uint) (interface{}, error) {
	var days, hours, minutes, seconds, microseconds C.sb4

	if CTrace {
		ctrace("OCIIntervalGetDaySecond(env=%p, err=%p, handle=%p)",
			v.environment.handle, v.environment.errorHandle, v.getHandle(pos))
	}
	if err := v.environment.CheckStatus(
		C.OCIIntervalGetDaySecond(unsafe.Pointer(v.environment.handle),
			v.environment.errorHandle,
			&days, &hours, &minutes, &seconds, &microseconds,
			//(*C.OCIInterval)(v.getHandle(pos))),
			getIntervalHandle(v, pos)),
		"internalVar_GetValue"); err != nil {
		return nil, err
	}
	return (time.Duration(days)*24*time.Hour +
		time.Duration(hours)*time.Hour +
		time.Duration(minutes)*time.Minute +
		time.Duration(seconds)*time.Second +
		time.Duration(microseconds)*time.Microsecond), nil
}