Esempio n. 1
0
// Initialize the variable.
func lobVarInitialize(v *Variable, cur *Cursor) error {
	if CTrace {
		ctrace("%s.lobVarInitialize", v)
	}
	// initialize members
	v.connection = cur.connection
	// v.isFile = v.typ == BFileVarType

	// initialize the LOB locators
	//dst := unsafe.Pointer(&v.dataBytes[0])
	if err := v.environment.CheckStatus(
		C.lobAlloc(v.environment.handle, unsafe.Pointer(&v.dataBytes[0]), //unsafe.Pointer(&dst),
			C.int(v.allocatedElements)),
		"DescrAlloc"); err != nil {
		return err
	}
	/*
		var (
			x   **C.OCILobLocator
			err error
		)
		for i := uint(0); i < v.allocatedElements; i++ {
			x = (**C.OCILobLocator)(v.getHandle(i))
			if err = v.environment.CheckStatus(
				C.OCIDescriptorAlloc(unsafe.Pointer(v.environment.handle),
					(*unsafe.Pointer)(unsafe.Pointer(x)), C.OCI_DTYPE_LOB, 0, nil),
				"DescrAlloc"); err != nil {
				return err
			}
			if CTrace {
				ctrace("lobVarInitialize(x=%p (%x))", x, x)
			}
			v.setHandle(i, unsafe.Pointer(*x))
			if CTrace {
				ctrace("lobVarInitialize(env=%p, i=%d, lob=%x)",
					v.environment.handle, i, v.getHandleBytes(i))
			}
		}
	*/

	return nil
}
Esempio n. 2
0
// Initialize the variable.
//
// see http://www-rohan.sdsu.edu/doc/oracle/appdev.102/b14249/adlob_lob_ops.htm#g1113588
// http://www-rohan.sdsu.edu/doc/oracle/appdev.102/b14250/oci16msc002.htm#CIHEEEHI
//
// The given Cursor is not used, only its Connection.
func lobVarInitialize(v *Variable, cur *Cursor) error {
	if CTrace {
		ctrace("%s.lobVarInitialize", v)
	}
	// initialize members
	v.connection = cur.connection
	// v.isFile = v.typ == BFileVarType

	// initialize the LOB locators
	//dst := unsafe.Pointer(&v.dataBytes[0])
	//status := C.lobAlloc(v.environment.handle, unsafe.Pointer(&dst),
	status := C.lobAlloc(v.environment.handle, unsafe.Pointer(&v.dataBytes[0]),
		C.int(v.allocatedElements))
	if CTrace {
		ctrace("%s.lobAlloc(env=%p, &dataBytes=%p (len=%d), allocElts=%d): %d, handle=%p",
			v, v.environment.handle, &v.dataBytes[0], len(v.dataBytes), v.allocatedElements, status,
			v.getHandle(0))
	}
	if err := v.environment.CheckStatus(status, "DescrAlloc"); err != nil {
		return errgo.Mask(err)
	}

	return nil
}