Solved

How can I insert a large field into Infomix database using TQuery.

Posted on 1997-05-28
1
212 Views
Last Modified: 2010-04-06
How can I insert/update a large field (more than 255 bytes, such as BLOB) into SQL database (informix5) using TQuery in Delphi 2.0 ?
0
Comment
Question by:serg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
batsoft earned 200 total points
ID: 1336626
You can not do so with Insert or Update SQL statements.
1. Be shure that your query result set have RequestLive property = TRUE.
1. Locate  record you need to update.
Source Follows;
procedure UpdateField(FieldName:String;Q:TQuery;Src:TStream);
const
 BufSize = 4096; {we will trasnfer all with 4k buffer}
var
 B:TBlobStream
 Buf:Pointer;
 BytesRead:Integer;
begin
 {Src TStream object (TFileStream,TBlobSTream etc. wich contains data to be updated}
 GetMem(Buf,BufSize);
 B := TBlobStream((Q.FindField(FieldName) as TBlobField), bmOpenWrite);

 try
  repeat
    {Read source data}
   BytesRead := Src.Read(Buf^,BufSize);
  {Write data to field}
   B.Write(Buf^,BytesRead);
 until  BytesRead <> BufSize;
 finally
 {Close streams}
  B.Free;
 FreeMem(Buf,BufSize);
end;
{You can call this method whenever you need update blob field contents., before open stream to source data and put record in edit or insert state, after call Post or CheckBrowseMode}

0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

717 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