xHarbour Reference Documentation > Function Reference |
Loads data of a binary large object (BLOB) into memory.
BlobDirectGet( <nBlobID>, [<nStart>], [<nCount>] ) --> xBlobData
Note: Both parameters, <nStart> and <nCount>, are ignored if the BLOB does not contain a character string.
The function returns the BLOB data loaded into memory. The data type of a BLOB depends on the stored BLOB. It can be determined using function Valtype().
BlobDirectGet() loads the contents of a single binary large object (BLOB) into memory. The object is identified by its numeric ID. A BLOB is stored either in a memo field (DBFCDX RDD) or in a stand alone DBV file which is not associated with a database file (DBFBLOB RDD). BlobDirectGet() is usually required for the latter case. If BLOBs are stored in a database with an associated memo file, function BlobGet() is more comfortable to use, since it accepts a numeric field position of a memo field, rather than a numeric BLOB identifier.
The numeric BLOB ID is obtained using DbFieldInfo() or must be taken from the array returned by BlobRootGet().
Notes: BLOBs are stored in memo files having the .FPT or .DBV extension. They are maintained by the RDDs DBFCDX or DBFBLOB. DBFNTX, in contrast, does not support BLOBs.
The file Blob.ch must be #included for BlobDirectGet() to work.
See also: | BlobDirectExport(), BlobDirectImport(), BlobDirectPut(), BlobExport(), BlobRootGet(), DbFieldInfo() |
Category: | Blob functions , Database functions |
Header: | blob.ch |
Source: | rdd\dbcmd.c, rdd\dbffpt\dbffpt1.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example demonstrates two possibilities of loading BLOB data. // The first example uses the DBFCDX RDD while the second uses the // DBFBLOB RDD which does not maintain a database file, but only the // BLOB file. #include "Blob.ch" REQUEST DBFBLOB REQUEST DBFCDX PROCEDURE Main LOCAL nBlobID, nFieldPos LOCAL aBlobID LOCAL cImage // DBF and FPT file exist USE PhotoArchive ALIAS Photos VIA "DBFCDX" LOCATE FOR FIELD->PhotoName = "Sunset in Malibu" IF Found() // Get numeric field position nFieldPos := FieldPos( "JPEG" ) // Get numeric BLOB ID nBlobID := DbFieldInfo( DBS_BLOB_POINTER, nFieldPos ) // Load BLOB cImage := BlobDirectGet( nBlobID ) // < ... process BLOB data ... > ENDIF // Only DBV file exists USE BlobStorage ALIAS Blob VIA "DBFBLOB" aBlobID := BlobRootGet() IF Valtype( aBlobID ) == "A" // Load second BLOB cImage := BlobDirectGet( nBlobID[2] ) // < ... process BLOB data ... > ELSE ? "Error: Blob root is not created" ENDIF USE RETURN
http://www.xHarbour.com