Solved

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

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 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