Exemple #1
0
// Open the LOB to speed further accesses.
func (lv *ExternalLobVar) Open() error {
	if err := lv.Verify(); err != nil {
		return err
	}
	// Py_BEGIN_ALLOW_THREADS
	return lv.lobVar.environment.CheckStatus(
		C.OCILobOpen(lv.lobVar.connection.handle,
			lv.lobVar.environment.errorHandle,
			(*C.OCILobLocator)(unsafe.Pointer(&lv.lobVar.dataBytes[lv.pos*lv.lobVar.size])),
			C.OCI_LOB_READWRITE),
		"LobOpen")
	// Py_END_ALLOW_THREADS
}
// Open the LOB to speed further accesses.
func (lv *ExternalLobVar) Open() error {
	if err := lv.Verify(); err != nil {
		return err
	}
	// Py_BEGIN_ALLOW_THREADS
	if CTrace {
		ctrace("OCILobOpen(conn=%p, lob=%x, OCI_LOB_READWRITE)",
			lv.lobVar.connection.handle, lv.getHandleBytes())
	}
	return lv.lobVar.environment.CheckStatus(
		C.OCILobOpen(lv.lobVar.connection.handle,
			lv.lobVar.environment.errorHandle,
			lv.getHandle(), C.OCI_LOB_READWRITE),
		"LobOpen")
	// Py_END_ALLOW_THREADS
}
Exemple #3
0
func lobOpen(ses *Ses, lob *C.OCILobLocator, mode C.ub1) (length C.oraub8, err error) {
	//Log.Infof("OCILobOpen %p\n%s", lob, getStack(1))
	r := C.OCILobOpen(
		ses.ocisvcctx,      //OCISvcCtx          *svchp,
		ses.srv.env.ocierr, //OCIError           *errhp,
		lob,                //OCILobLocator      *locp,
		mode)               //ub1              mode );
	//Log.Infof("OCILobOpen %p returned %d", lob, r)
	if r != C.OCI_SUCCESS {
		lobClose(ses, lob)
		return 0, ses.srv.env.ociError()
	}
	// get the length of the lob
	r = C.OCILobGetLength2(
		ses.ocisvcctx,      //OCISvcCtx          *svchp,
		ses.srv.env.ocierr, //OCIError           *errhp,
		lob,                //OCILobLocator      *locp,
		&length)            //oraub8 *lenp)
	if r == C.OCI_ERROR {
		lobClose(ses, lob)
		return length, ses.srv.env.ociError()
	}
	return length, nil
}