Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-08

Reading\Writing Blobs (Maybe off-topic)

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Andreas Berger

Sorry for this possible off-topic mail. I should ask at Zeos, but since I do not subscribe to their list I thought to try here.

I need to read and write a blob (record) to a firebird database. I am using Zeos but no db-aware components. In other words I use only datasets and queries with SQL.Text and open or ExecSQL. I know that some people convert the data replacing zeros with some escape sequence. But I would like to avoid this since most of the time most of the data is zero.

The question how do you read a blob using SQL.Text and Open, and write using SQL.Text and ExecSQL?

Grateful for any good solution,
Andreas

Birger Jansen
to Andreas Berger

I have experience with firebird, blob fields, and a little bit zeos, but not with the combination of all three together. We always use blobs with (memory)streams and parameters. A query then looks like

MyQuery.SQL.Text := 'UPDATE BlobTable SET BlobField = :BlobField WHERE MyID = :MyID'

And the query-parameter is set:

MyQuery.Params.ParamByName('BlobField').LoadFromStream(MemSt, ftBlob);

Maybe you have the same options in Zeos?

Kind regards,
Birger

Show quoted text 27 lines
-----Oorspronkelijk bericht----- Van: Andreas Berger [mailto:] Verzonden: donderdag 19 augustus 2010 0:44 Aan: Lazarus mailing list Onderwerp: [Lazarus] Reading\Writing Blobs (Maybe off-topic) Sorry for this possible off-topic mail. I should ask at Zeos, but since I do not subscribe to their list I thought to try here. I need to read and write a blob (record) to a firebird database. I am using Zeos but no db-aware components. In other words I use only datasets and queries with SQL.Text and open or ExecSQL. I know that some people convert the data replacing zeros with some escape sequence. But I would like to avoid this since most of the time most of the data is zero. The question how do you read a blob using SQL.Text and Open, and write using SQL.Text and ExecSQL? Grateful for any good solution, Andreas -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Andreas Berger
to Birger Jansen

Interesting. So you load via a stream? Do you first write the blob to the stream, rewind and then pass it to the parameters?

Regards
Andreas

Birger Jansen wrote 12 lines
I have experience with firebird, blob fields, and a little bit zeos, but not with the combination of all three together. We always use blobs with (memory)streams and parameters. A query then looks like MyQuery.SQL.Text := 'UPDATE BlobTable SET BlobField = :BlobField WHERE MyID = :MyID' And the query-parameter is set: MyQuery.Params.ParamByName('BlobField').LoadFromStream(MemSt, ftBlob); Maybe you have the same options in Zeos? Kind regards, Birger
Birger Jansen
to Andreas Berger
Interesting. So you load via a stream? Do you first write the blob to the stream, rewind and then pass it to the parameters?

That is exactly how we do it!

Kind regards,
Birger Jansen