?
Solved

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

Posted on 1997-05-28
1
Medium Priority
?
213 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 400 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

770 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