BLOBTOFILE (Copy Data from BLOB Field to File)

Top  Previous  Next

 

BLOBTOFILE( bloblabel, filename )

BLOBTOFILE

Copy the contents of a BLOB field to an external file.

bloblabel

The fully qualified label of the BLOB field. (Example: Customer.BlobImage)

filename

A string constant or variable that names the output file where the BLOB will be copied.

 

BLOBTOFILE is used to copy the contents of a BLOB to an external file. If the copy fails for any reason, BLOBTOFILE returns the ERRORCODE posted.

BLOBTOFILE (and FILETOBLOB) are simply binary-to-binary operations.

 

If you need to save images to a BLOB, and later restore them to an output file, the type of image should also be saved in the database (JPG, GIF, BMP, etc.). Using BLOBTOFILE to save to a different extension can produce unpredictable results.

To add this function to your existing applications, you need only include the CWUTIL.INC file in the Global Map section of your program:

INCLUDE('CWUTIL.INC'),ONCE

Return Data Type:     SIGNED

Example:

IF BLOBTOFILE(CUS:ImageBlob, 'imagename.jpg')  !returns an ERRORCODE if copy fails

 MESSAGE('BLOB did not copy due to the following ERRORCODE: ' & ERRORCODE())

END

 

See Also:

FILETOBLOB

BLOB