Ejemplo n.º 1
0
// GetFileName returns the directory alias and file name for the BFILE lob.
func (lv *ExternalLobVar) GetFileName() (string, string, error) {
	var err error
	// determine the directory alias and name
	if err = lv.Verify(); err != nil {
		return "", "", errgo.Mask(err)
	}
	dirAliasB := make([]byte, 120)
	nameB := make([]byte, 1020)
	var dirAliasLength, nameLength C.ub2

	if CTrace {
		ctrace("OCILobGetFilename(conn=%p, lob=%x, &dirAlias=%p, &dirAliasLen=%p, &name=%p, &nameLen=%p)",
			lv.lobVar.connection.handle, lv.getHandleBytes(),
			&dirAliasB[0], &dirAliasLength,
			&nameB[0], &nameLength)
	}
	if err = lv.lobVar.environment.CheckStatus(
		C.OCILobFileGetName(lv.lobVar.environment.handle,
			lv.lobVar.environment.errorHandle,
			lv.getHandle(),
			(*C.OraText)(&dirAliasB[0]), &dirAliasLength,
			(*C.OraText)(&nameB[0]), &nameLength),
		"LobFileGetName"); err != nil {
		return "", "", errgo.Mask(err)
	}

	return string(dirAliasB[:dirAliasLength]), string(nameB[:nameLength]), nil
}
Ejemplo n.º 2
0
// GetFileName returns the directory alias and file name for the BFILE lob.
func (lv *ExternalLobVar) GetFileName() (string, string, error) {
	var err error
	// determine the directory alias and name
	if err = lv.Verify(); err != nil {
		return "", "", err
	}
	dirAliasB := make([]byte, 120)
	nameB := make([]byte, 1020)
	var dirAliasLength, nameLength C.ub2

	if err = lv.lobVar.environment.CheckStatus(
		C.OCILobFileGetName(lv.lobVar.environment.handle,
			lv.lobVar.environment.errorHandle,
			(*C.OCILobLocator)(unsafe.Pointer(&lv.lobVar.dataBytes[lv.pos*lv.lobVar.size])),
			(*C.OraText)(&dirAliasB[0]), &dirAliasLength,
			(*C.OraText)(&nameB[0]), &nameLength),
		"LobFileGetName"); err != nil {
		return "", "", err
	}

	return string(dirAliasB[:dirAliasLength]), string(nameB[:nameLength]), nil
}
Ejemplo n.º 3
0
func (def *defBfile) value() (value interface{}, err error) {
	var bfileValue Bfile
	bfileValue.IsNull = def.null < C.sb2(0)
	if !bfileValue.IsNull {
		// Get directory alias and filename
		dLength := C.ub2(len(def.directoryAlias))
		fLength := C.ub2(len(def.filename))
		r := C.OCILobFileGetName(
			def.rset.stmt.ses.srv.env.ocienv,                     //OCIEnv                   *envhp,
			def.rset.stmt.ses.srv.env.ocierr,                     //OCIError                 *errhp,
			def.ociLobLocator,                                    //const OCILobLocator      *filep,
			(*C.OraText)(unsafe.Pointer(&def.directoryAlias[0])), //OraText                  *dir_alias,
			&dLength, //ub2                      *d_length,
			(*C.OraText)(unsafe.Pointer(&def.filename[0])), //OraText                  *filename,
			&fLength) //ub2                      *f_length );
		if r == C.OCI_ERROR {
			return value, def.rset.stmt.ses.srv.env.ociError()
		}
		bfileValue.DirectoryAlias = string(def.directoryAlias[:int(dLength)])
		bfileValue.Filename = string(def.filename[:int(fLength)])
	}
	value = bfileValue
	return value, err
}