TMSQuery to/from Binary & JSON

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
hsvandrew
Posts: 9
Joined: Fri 06 May 2016 01:22

TMSQuery to/from Binary & JSON

Post by hsvandrew » Fri 06 May 2016 01:50

Hi,

We currently use the following method to turn MSSQL returned data into binary for transmission through RemObjects. Is it possible to get raw data into binary from MSSQL faster than this method?

Would it be possible to build in a saveToBinaryStream/loadFromBinaryStream method directly into TMSQuery?

Also a saveToJSON would be very good as well, using the fastest JSON library available.

var
query: TMSQuery;
VirtualTable: TVirtualTable;
begin
query := db.CreateMSQuery( ); //returns TMSQuery
query.SQL.Text := 'select * from [table]';
query.open;
result := binary.create;
VirtualTable := TVirtualTable.Create(nil);
VirtualTable.Assign(query);
VirtualTable.saveToStream( result );
VirtualTable.free;
query.free;
end;

hsvandrew
Posts: 9
Joined: Fri 06 May 2016 01:22

Re: TMSQuery to/from Binary & JSON

Post by hsvandrew » Fri 06 May 2016 01:59

I just noticed Microsoft SQL Server 2016 will support direct output of data to JSON like it does XML. Therefore the to JSON feature might not be required but would be nice to see it built in anyway to support older versions of SQL using a Delphi JSON formatter, and SQL 2016 + using the inbuilt returned JSON data

azyk
Devart Team
Posts: 1058
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: TMSQuery to/from Binary & JSON

Post by azyk » Tue 10 May 2016 11:18

Try using methods TBlob.SaveToStream and TBlob.LoadFromStream for transmission of field value as raw data. For example:

Code: Select all

  MSQuery.Open;
  ...
  MSQuery.GetBlob(FieldName).SaveToStream(AStream);
  ...
  MSQuery.GetBlob(FieldName).LoadFromStream(AStream);
See more details about the Tblob class in SDAC documentation: https://www.devart.com/sdac/docs/?devart.dac.tblob.htm

hsvandrew
Posts: 9
Joined: Fri 06 May 2016 01:22

Re: TMSQuery to/from Binary & JSON

Post by hsvandrew » Tue 17 May 2016 00:13

Hi azyk,

You don't understand my question/code sample.

We want to turn the entire returned result set/dataset into a binary format, not just a single field.

We want to do this in the fastest possible way...

azyk
Devart Team
Posts: 1058
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: TMSQuery to/from Binary & JSON

Post by azyk » Fri 20 May 2016 09:31

Currently, in the TMSQuery dataset there are no methods for saving query results in JSON or binary formats. You can leave a suggestion at our UserVoice page: https://devart.uservoice.com/forums/104 ... components . If the suggestion collects enough votes, we will consider the possibility to implement it.

Post Reply