KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: How to check the size of blobs via SQL
PRODUCT: 4D | VERSION: 12.3 | PLATFORM: Mac & Win
Published On: March 1, 2012

The BIT_LENGTH SQL function can easily be used in a SELECT statement to accomplish the task of getting the size of blobs. Here is an example:

ARRAY LONGINT($nSize_al)
Begin SQL
  SELECT BIT_LENGTH(blob)
  FROM Table
  INTO :$nSize_al;

End SQL


In the example code above, the size of [Table]blob for all records is returned into the $nSize_al array.

--------------------------------------------------------------------------------

The BIT_LENGTH SQL function can also be used in a WHERE clause like this:

ARRAY LONGINT($nSize_al)
Begin SQL
  SELECT ID
  FROM Table
  WHERE BIT_LENGTH(blob) > 1024
  INTO :$nSize_al;
End SQL


In the example above, the $nSize_al array is filled with the [Table]ID for all records whose [Table]blob is greater than 1024 bits.



The BIT_LENGTH SQL function can be particularly useful when dealing with an external 4D database via SQL.