0

Whenever ADO (DBgo) will be disontinued or someone wants to bring an ADO-Windows based application to the UNIX world withourt rewritting the application a translation of the ADO classes given in the unit unit Data.Win.ADODB; to new correponding ZEOS based classed might help here. For TADOConnection a mapping into TZConnection during this excange is obvious, same for TADOTable, TADOQuery .....

For starting this job for not yet existing classes now need to convert this code is using the TADOBlobStream class. As mentioned I want to create a TZEOSBLobStream Class instead of it to minimize code refactoring work

What is the best way to create a compatible class in ZEOS ? And how to consider the other classes given in the ADO unit like

  • TADOCommand = class; TCustomADODataSet = class; TADODataSet = class; TParameters = class; .....

    TADOCommand = class;

    TCustomADODataSet = class;

    TADODataSet = class;

    TParameters = class;

    ;

user9044066
  • 107
  • 2
  • 11
  • I think they should be compatible (if you handled BLOBs properly by creating BLOB stream by the dataset object). – Victoria Feb 13 '18 at 16:36
  • TZBlobStream = class(TMemoryStream); should be the starting point, now it comes to the implementaion section of this class where I can't find more good information – user9044066 Feb 13 '18 at 16:41
  • I don't understand what you mean. `TADOBlobStream` is also a `TMemoryStream` descendant. What you're supposed to do in both libraries is declaring a `TStream` variable to which you assign stream created by the dataset object's `CreateBlobStream` and with which you work (write or read from it). When you do that in your application, you can simply replace libraries since they both have this stuff implemented. – Victoria Feb 13 '18 at 16:51
  • I want to imitate the ADO TADOBlobStream class with stuff available using ZEOS DB libraries, In end my just exchaning this class my code should run with ADO or ZEOS components. – user9044066 Feb 13 '18 at 18:17
  • I still don't understand why. What's so special on `TADOBlobStream`, `Truncate` method? Or why do you want to work with a specific BLOB stream implementation? I just cannot see anything to exchange. You're supposed to work with the abstraction (`TStream` descendant instance returned by `CreateBlobStream` method), not with a specific library implementation. – Victoria Feb 13 '18 at 20:49
  • I need the same mapping for TADODataSet to a TZdataset. and later on for many of these ADO classes. My question goes in general " how to make a logic mapping between the datatypes defined unit Data.Win.ADODB; and the best correponding class already defined in ZEOS. How to make the bridge between both systems - that one delphi code = my application can work on both DB interface on demand with mimimum code exchange work – user9044066 Feb 13 '18 at 21:20
  • Well, the point is that you don't need to do anything. `TDataSet` already provides you abstract interface. For all types, including BLOB fields. Its implementors, if it's ADO dataset, or ZEOS dataset implements their internal methods. If you wrote your application well, you can simply replace the library components and nothing in the code will get changed. – Victoria Feb 13 '18 at 21:39
  • Any progress in this topic, please? – Victoria Mar 24 '18 at 22:27

1 Answers1

0

You're not supposed to use specific BLOB stream implementation nor implement your own. That's what the libraries are shipped with. You're expected to use abstract layer interface provided by the common TDataSet class. It has the CreateBlobStream method that returns instance of a specific library BLOB stream class implementation as abstract TStream class to interface with.

And working just with this returned TStream instance is in most cases all you really need. It's very common way to work with BLOB streams, independent from the used library. For example in code like this, MyDataSet can be ADO, ZEOS or theoretically any properly implemented dataset object:

var
  Stream: TStream;
begin
  Stream := MyDataSet.CreateBlobStream(MyDataSet.FieldByName('MyBlob'), bmReadWrite);
  try
    { ← read of write from or to the Stream here }
  finally
    Stream.Free;
  end;
end;

So even if that may be difficult in your case, I would highly recommend you to refactor your code to use the abstract layer of the TDataSet class wherever possible.

Victoria
  • 7,822
  • 2
  • 21
  • 44