Recent

Author Topic: Loading and Retrieving a large Text Blob in Firebird  (Read 5909 times)

cov

  • Sr. Member
  • ****
  • Posts: 250
Loading and Retrieving a large Text Blob in Firebird
« on: June 15, 2013, 04:32:08 pm »
I have a large Text File which I want to load, line-by-line into a Firebird SUB_TYPE 1 BLOB.

The following should work, but some of the lines may not be relevant and some of the lines will be blank.

Code: [Select]
SQLQuery1.SQL.Text:= 'insert into ODTABLE (Content) values (:Content)';
SQLQuery1.ParamByName('Content').LoadFromFile(TextFileName, ftBlob);

Also, how do I extract the Content once it is loaded into the Database?

goodname

  • Sr. Member
  • ****
  • Posts: 297
Re: Loading and Retrieving a large Text Blob in Firebird
« Reply #1 on: June 16, 2013, 04:52:44 pm »
Looks like you need the get familiar with file streams. Have not used file streams so don't really know the function names to use.

Saving to database
var strm: TmemoryStream;
//load file to stream.
//edit stream.
SQLQuery1.SQL.Text:= 'insert into ODTABLE (Content) values (:Content)';
SQLQuery1.Params[0].LoadFromStream(strm,ftBlob);

Reading from database
var strm: Tstream;
SQLQuery1.SQL.Text:='SELECT content FROM ODTABLE WHERE id=1;';
strm:=SQLQuery1.CreateBlobStream(SQLQuery1.Fields[0],bmRead);

 

TinyPortal © 2005-2018