xHarbour Reference Documentation > Function Reference |
Assigns data to a binary large object (BLOB).
BlobDirectPut( <nOldblobID>, <xBlobData> ) --> nNewblobID
All data of <nOldBlobID> is discarded, and the BLOB receives a new ID which is returned by the function. If zero is passed, a new BLOB is added to the BLOB file.
The function returns a numeric value which is the BLOB identifier of the new BLOB. The return value is zero, when the operation fails.
BlobDirectPut() assigns the value of <xBlobData> to a single binary large object (BLOB). 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). BlobDirectPut() is usually required for the latter case. If BLOBs are stored in a database with an associated memo file, function FieldPut() 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().
When data is assigned to an existing BLOB, the BLOB is entirely discarded and a new BLOB is created. As a consequence, the existing BLOB ID <nOldBlobID> becomes invalid, and BlobDirectPut() returns a new BLOB ID. The imported data can only be accessed via the new BLOB ID.
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 BlobDirectPut() to work.
See also: | BlobDirectExport(), BlobDirectGet(), BlobDirectImport(), 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 how to collect contents of files // in a single DBV file. #include "Blob.ch" REQUEST DBFBLOB PROCEDURE Main LOCAL aFile, cText LOCAL aFiles := Directory( "*.prg" ) LOCAL aBlobID := {} DbCreate( "Repository", {}, "DBFBLOB" ) USE Repository NEW VIA "DBFBLOB" FOR EACH aFile IN aFiles cText := MemoRead( aFile[1] ) AAdd( aBlobID, BlobDirectPut( 0, cText ) ) NEXT IF BlobRootLock() .AND. BlobRootPut( aBlobID ) BlobRootUnlock() ELSE Alert( "Unable to lock BLOB root;try again later" ) ENDIF USE RETURN
http://www.xHarbour.com