KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Enhanced Storing and Retrieving BLOBs in Pictures
PRODUCT: 4D | VERSION: 11.2 | PLATFORM: Mac & Win
Published On: November 25, 2008

In 4D v11 SQL Release 2 the command BLOB TO PICTURE was modified to accept an optional third parameter: codec. You can pass a string in this parameter to specify the codec to use for decoding the BLOB. If you pass a 4D recognized codec in the third parameter it is applied to the BLOB.

If you pass an unrecognized 4D codec, a new codec is recorded dynamically with the ID passed in the parameter and 4D returns a picture that encapsulates the BLOB and the OK variable is set to 1. To retrieve the BLOB, you will need to use the PICTURE TO BLOB command with the same custom ID.

The implementation of these mechanisms allows, more specifically, the creation of "BLOB arrays" via picture arrays. This technique must be used with caution; since the arrays are loaded entirely into memory, working with large sized BLOBs can affect the functioning of the application.

A BLOB created by the VARIABLE TO BLOB command is managed automatically; it is not necessary to pass a codec to encapsulate it since the BLOB is "signed." In this case, for the opposite operation, you will need to pass ".4DVarBlob" to the PICTURE TO BLOB command as the codec ID.

A BLOB created by the VARIABLE TO BLOB command is not the only instance in which the signing of the 4D BLOB is done automatically. In the case where BLOBs are stored in picture arrays via an SQL SELECT statement, you will need to pass ".4DBlob" to the PICTURE TO BLOB command as the codec ID.

For more information see the 4th Dimension Language Reference at: http://www.4d.com/docs/CMU/CMU00682.HTM.