xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

BlobDirectPut()

Assigns data to a binary large object (BLOB).

Syntax

BlobDirectPut( <nOldblobID>, <xBlobData> ) --> nNewblobID

Arguments

<nOldBlobID>
<nOldBlobID> is the numeric identifier of the binary large object to assign <xBlobData> to. The ID can be obtained using functions BlobDirectPut() or DbFieldInfo( DBS_BLOB_POINTER, <nFieldPos> ). An array of blob IDs can also be obtained using BlobRootGet() when the blob IDs are previously written to the root area of a blob file.

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.

<xBlobData>
This is the value to assign to the BLOB. The supported data type of <xBlobData> can vary between RDDs maintaining BLOB files.

Return

The function returns a numeric value which is the BLOB identifier of the new BLOB. The return value is zero, when the operation fails.

Description

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.

Info

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

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe