I have a TClientDataSet with several records, and I want o load all the records, but load the blob field on Demand, one at a time.
I noticed that calling FetchBlobs twice fetches the blob twice and also that checking the field's IsNull property always returns False.
So the only solution I found so far is to access a property like Value or BlobSize and if the blob has not been fetched an exception is raised EDBClient with message "Blob has not been fetched", so if this exception is raised I call the FetchBlobs.
Is there some better way of doing this?
try
cdsIMG.BlobSize;
except
on E: EDBClient do
cds.FetchBlobs;
end;
poFetchBlobsOnDemand
is set together withFetchOnDemand
of the dataset, the behavior is already as you describe. I.e. the client data set callsFetchBlobs
only if it the blob data has not already been retrieved and only when it is needed (See code in 'TCustomClientDataSet.CreateBlobStream' in DBClient.pas). I don't understand why you have to duplicate the exact behavior manually.. – Gally