Subject RE: [IBO] Storing Strings longer than 255 characters
Author Helen Borrie
At 03:56 PM 22-08-02 +0200, Jason Fischer wrote:

>Could you explain what sub_type 1 is. I am new to FB and don't know how
>everything works yet.

If you check back on Geoff's recent postings (including one yesterday) you
will find a useful list of learning resources for Firebird. As a rule,
questions about how the database works are off-topic in this list but we'll
make an exception for you this time. :-)

To the database, blobs ("binary large objects") are just streams of
bytes. But, in Firebird and InterBase, you can use a feature called a blob
filter to "interpret" that byte-soup into something that a client
application can recognise. Sub_type identifies the blob filter. Sub_type 0
is just a blob with no filter.

FB/IB come with a few "ready-made" blob filters, including one that is
available that converts the soup into ascii text - this is sub_type 1. Of
course, you have to push ascii text into the blob in order for it to be
converted to text again when retrieved.

You can make your own blob filters - e.g. a routine to convert a PDF file
stream into ascii text or to convert a blob in one graphics format to
another - in Delphi or another language - and compile them into a
dll. It's really just a special category of UDF. User-defined blob
filters have to be assigned sub-types less than zero. The sub_types > 0
are reserved for internally-defined ones. Those > 1 are normally
unavailable - they are used internally in the creation, storage and
retrieval of data in the system tables.

But - keeping life simple for now - most people manage to live very happily
without custom blob filters. Sub_type 1 works just fine for plain
text. You can store RTF files in sub_type 1 in an IBO system, too, and
view/edit it in a TIB_RichEdit.

The database engine doesn't care what you push into a blob so it's totally
up to the programmer to take care that you don't apply an invalid blob
filter by e.g. trying to store a Word file in a sub_type 1 blob. But you
can store a Word file in a sub_type zero blob just fine. IBO has plenty of
tricks for moving blobs around and, in your application, you can set up an
automation object for doing live editing on your blobbed Word files inside
the app.