Esempio n. 1
0
// Initialize the variable.
func cursorVar_Initialize(v *Variable, cur *Cursor) error {
	var tempCursor *Cursor
	var err error

	v.connection = cur.connection
	v.cursors = make([]*Cursor, v.allocatedElements)
	for i := uint(0); i < v.allocatedElements; i++ {
		tempCursor = v.connection.NewCursor()
		if err = tempCursor.allocateHandle(); err != nil {
			return err
		}
		C.cursorVar_setHandle(unsafe.Pointer(&v.dataBytes[i]), tempCursor.handle)
	}

	return nil
}
Esempio n. 2
0
// Set the value of the variable.
func cursorVar_SetValue(v *Variable, pos uint, value interface{}) error {
	x, ok := value.(*Cursor)
	if !ok {
		return fmt.Errorf("requires *Cursor, got %T", value)
	}

	var err error
	v.cursors[pos] = x
	if !x.isOwned {
		if err = x.freeHandle(); err != nil {
			return err
		}
		x.isOwned = true
		if err = x.allocateHandle(); err != nil {
			return err
		}
	}
	C.cursorVar_setHandle(unsafe.Pointer(&v.dataBytes[pos]), x.handle)
	x.statementType = -1
	return nil
}