Exporting BLOB Data

Top  Previous  Next

RelDBQueryProcess and RelDBQueryDataSource, support exporting binary data stored in BLOB (Binary Large Object) type table fields to file system.

By using this feature; with one query, the data stored in other type of fields can be retrieved and the binary data stored in BLOB fields can be exported to external files so that the web browsers can directly access them.

An Export BLOB Data Definition can be made where the SQL statement query is but it must be enclosed with SQL comment symbols.

Definition Syntax:

_EXPORT_BLOB_DATA(export-directorykey-fieldsblob-fieldschange-detection-fields)

 

Parameters

export-directory

The name of the directory where the BLOB fields will be exported to. Although this definition can be made absolute or relative to the root directory of the web application, generally the using the relative definition makes sense; because the export directory should be accessible by the browsers.

 

key-fields

The exported files should be named uniquely in order to prevent the file name collision. Therefore this parameter should be given one or more field names (separated with commas) whose values build a table based unique identity.

 

blob-fields

The name of the BLOB fields whose values will be exported to external files. One or more (separated with commas) BLOB field names can be given. After each BLOB field name an ':' character and the extension name of the export file should be specified. This extension name is actually defines the content type of the binary data stored in the BLOB field.

 

change-detection-fields

This optional parameter is used to detect a change in the current record. This way unnecessary exporting of the BLOB fields can be avoided. If one or more fields are available whose content can indicate the change in the current record you can define the names of the fields in this parameter.

If it is not defined, then the BLOB export will be repeated once a ten-seconds.

 

Examples:

 

/* _EXPORT_BLOB_DATA(product_pictures; ID; PICTURE:jpg)  */

 

select * from products

 

 

/* _EXPORT_BLOB_DATA(pictures; NAME, SURNAME, DEPARTMENT; PICTURE:jpg; MODIFIED_DATE)  */

 

select * from employees

 

 

/* _EXPORT_BLOB_DATA(documents; ID; PROPOSAL:doc, DEMO:ppt; MODIFIED_DATE)  */

 

select * from documents

 

The definition can be processed conditionally where necessary.

 

@doif(EXPORT_DOCS)

  /* _EXPORT_BLOB_DATA(documents; ID; PROPOSAL:doc, DEMO:ppt; MODIFIED_DATE)  */

@doend()

 

select * from documents

 

The names of the files

The files that contain the exported binary data are given unique names and those names are then stored into the related result field.

 

 

/* _EXPORT_BLOB_DATA(documents; ID; PROPOSAL:doc, DEMO:ppt; MODIFIED_DATE)  */

 

select * from documents

 

Note that PROPOSAL and DEMO result fields will contain the names of the export files.