Solved

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

Posted on 1997-05-28
1
196 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
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 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

9 Experts available now in Live!

Get 1:1 Help Now