Saving to BLOB field in dbExpress with a join

Posted on 2003-11-13
Last Modified: 2008-01-16
Writing to and from Interbase BLOB fields in Delphi7 like this….

ClientDataset.FieldByName(‘NOTES’).AsString:=Memo.Text; fine until the underlying dataset is a join and the fields need to be written explicitly to the joined tables by the providers BeforeUpdateRecord event.
Building SQL statements in this event from the fields to be updated works for non-blob field but doesn’t work for BLOB fields as there is no INSERT syntax allowable for BLOB fields.
The question is therefore what should the providers BeforeUpdateRecord event look like to handle this kind of field? Is it possible to do it this way or is there another way?
A solution involving the datasets provider is preferable as this nicely encapsulates updates to all affected tables.
Question by:RogerFroud

Accepted Solution

RogerFroud earned 0 total points
ID: 9782120
This solution seems to work ok but is a bit clumsy. Any better solution gets the points....

Dataset Provider BeforeUpdateRecord event
    SQL: String;
    myParams: TParams;
    FileStream : TFileStream; //debug only
    StringStream : TStringStream;
code to save all other fields using INSERT statements in SQL then....

      if (DeltaDS.FieldByName('NOTES').NewValue<>Null) then
          myParams := TParams.Create;
          myParams.CreateParam(ftBlob, 'BlobParam', ptInput);
          myParams.ParamByName('BlobParam').LoadFromStream(StringStream, ftBlob);
          Connection.Execute(SQL, myParams);

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now