Data Access Builder provides support for mapping DB2 Large Objects (LOBs) to attributes in a C++ class. The class library provides classes and methods for handling the following large object types:
Class Library methods allow you to access the contents of a LOB, and then manipulate the contents in various ways, including inserting, removing, overlaying, concatenating, comparing, and finding the length. You can save a LOB to a file, or read one in from a file.
Data Access LOB support lets you control whether you work with LOBs by downloading them to the client space, or by accessing them on the database server. Since DB2 LOBs can be as large as 2.0 GB, you might not want to work with every LOB by downloading it. However, if your connection to the database server is not very fast, you might want to work on smaller LOBs on the client.
You can choose to work with all LOBs on the server or on the client, or you can let the application decide where to store LOBs based on their sizes. The threshold represents the critical LOB size. Objects smaller than the threshold value will be downloaded to the client; those larger than the threshold value will remain on the server and will be accessed from the client by using a database locator.
For example, if you set the threshold value to 5000 bytes, then objects smaller than 5000 bytes will be downloaded to the client for manipulation, while those larger than 5000 bytes will remain on the server. The LOB classes allow you to set the threshold from a data access application.
To work with LOBs on the server, the application uses a datastore connection, which also is set using class library methods. Warning! Turn auto-commit OFF for the LOB's datastore [that is, call theDatastore.enableAutocommit(false)]. Database locators become invalid after one transaction, and if the auto-commit setting is left on, then a LOB locator will be lost after the first time you do something with the LOB.
LOBs have another setting called delta. The delta is the tolerance for the threshold; it prevents the object being sent back and forth between the client and server if its size is hovering about the threshold. If the object is on the client, the delta is added to the threshold to determine the maximum size it can reach before being sent to the server. If the object is on the server, the delta is subtracted from the threshold to determine the minimum size it can reach before being sent to the client.
For example, suppose you set the class threshold to 500 bytes and the delta value to 25 bytes by running the following code:
IDALobDO.setClassThreshold( 500, 25 );
If the current LOB is 450 bytes, it will be stored on the client. If you add 60 bytes to it, for a total of 510 bytes, then it will still be kept on the client, even though it has passed the threshold, because of the delta (the upload threshold is effectively 525 bytes). If you then add 30 more bytes, for a total of 540 bytes, the LOB will be moved to the server. If you then remove 50 bytes from it, for a total of 490 bytes, it will still be kept on the server (the download threshold is effectively 475 bytes).
Support for DB2 Extended Scalar Functions for CLOBs
The class for CLOB support, IDAClobDO, contains C++ methods that run the DB2
Extended Scalar Functions for CLOBs, so that you can use these methods directly from a
data access application. Support exists for the following functions:
See the class library reference documentation for more information on all LOB support methods.
![]()
Data Access Class Library and Generated Code
