#1 2015-03-03 18:03:10

Chris75018
Member
From: France
Registered: 2012-09-14
Posts: 26
Website

Cannot find how to Read TbyteDynArray from TSQLTableJSON

Hi,

I didin't find how to read TByteDynArray Field from a TSQLHttpClientWinHTTP.list() result.

  TRHhisto = class(TSQLRecord)
  private
    fHisBuffer    : TRawUTF8DynArray;
    fHisMois      : TByteDynArray;
  public
    procedure Clear; override;
  published
    property hisBuffer   : TRawUTF8DynArray   read fHisBuffer   write fHisBuffer;
    property hisMois     : TByteDynArray      read fHisMois     write fHisMois;
  end;
{...}
var Table : TSQLTableJSON;
      bl : TSQLRawBlob;
{...}
  Table := Client.List([TRHhisto], 'rowID, HISPERID, HISMOIS', StringToUTF8(sWhere));
  if Table <> nil then 
  begin
     {...}
     bl := Table.getBlob(idx, Table.fieldIndex('HISMOIS'));

     ------> How to convert bl to a TByteDynArray variable ?

  end;

Thanks in advance.

Offline

#2 2015-03-03 19:39:59

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,203
Website

Re: Cannot find how to Read TbyteDynArray from TSQLTableJSON

Try to use Table.GetBytes() instead.

Offline

#3 2015-03-03 19:49:53

Chris75018
Member
From: France
Registered: 2012-09-14
Posts: 26
Website

Re: Cannot find how to Read TbyteDynArray from TSQLTableJSON

I've done it first with table.GetBytes but I have don't find how to load the TByteDynArray variable with it.
Do you have a sample. I dont find anything in the documentation and in the forum.

Thanks.

Offline

#4 2015-03-03 20:05:23

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,203
Website

Re: Cannot find how to Read TbyteDynArray from TSQLTableJSON

In fact, TBytes = TByteDynArray = array of byte.

So you can safely trans-type TBytes(aByteDynArrayVariable) and TByteDynArray(aBytesVariable) values directly.
In your case:

 aByteDynArrayVariable := TByteDynArray(Table.GetBytes(...))

Note: I answered to your private mail.

Offline

#5 2015-03-03 20:08:52

Chris75018
Member
From: France
Registered: 2012-09-14
Posts: 26
Website

Re: Cannot find how to Read TbyteDynArray from TSQLTableJSON

Thanks a lot.

Offline

#6 2015-03-04 11:10:47

Chris75018
Member
From: France
Registered: 2012-09-14
Posts: 26
Website

Re: Cannot find how to Read TbyteDynArray from TSQLTableJSON

Hi

when i use TByteDynArray(Table.GetBytes(...)) the result contains more bytes (7) than the stored array (perhaps Base64Encode ?).

With TByteDynArray(Table.GetBytes(...))  --> (1,0,12,15,18,48,54,1,2,3,4,5,6,7,8,9,10,11,12)
With client.Retrieve(row, MySQLrecord) --> (1,2,3,4,5,6,7,8,9,10,11,12)

But if i use MySQLRecord.FillFrom(Table) all is fine.
It's good for me.

Offline

Board footer

Powered by FluxBB