#1 2018-02-28 19:31:06

triguinhu
Member
From: Brazil
Registered: 2016-07-28
Posts: 27

RetrieveListJSON and TDocVariantData

Hi all

I Use this code:

var vValues: TDocVariantData;

    vValues.InitJSON(MyModelHttpClient.RetrieveListJSON(TSQLMyRecord,'',''),JSON_OPTIONS[true]);

but in some cases, result of RetriveListJSON call is 0 records.
In this cases, some information is added in vValues. I use vValues to fill a DbGrid.DataSource.DataSet :

    MyGrid.DataSource.DataSet := ToDataSet(self,vValues.Values,[],[]);

when 0 records is the result of RetrieveListJSON call, i have a exception _Self(0<>1) ...

Is there any way to find out if the number of records returned by RetrieveListJSON = 0 ?

Thanks

Rodrigo

Offline

#2 2018-03-05 13:46:05

mauriciobs
Member
From: Brazil
Registered: 2016-05-11
Posts: 16

Re: RetrieveListJSON and TDocVariantData

Hi Rodrigo, see the TDocVariantData "count" method.

Offline

#3 2018-03-07 13:46:49

triguinhu
Member
From: Brazil
Registered: 2016-07-28
Posts: 27

Re: RetrieveListJSON and TDocVariantData

Hi Mauricio,

Yes, I had seen this property, however it did not work properly in this case

Without any data in the table, the RetrieveList and vValues.InitJson method returns the following:

(275, [dvoIsObject, dvoReturnNullForUnknownProperty, dvoValueCopiedByReference], ('fieldCount', 'values',' rowCount '), (5,' ["ID", "Acronym", "Description", "Type", "Id_Merc") ', 0), 3)

And the count property returns the number 3, but there is no record in the table

Offline

#4 2018-03-07 15:26:02

EMartin
Member
From: Buenos Aires - Argentina
Registered: 2013-01-09
Posts: 337

Re: RetrieveListJSON and TDocVariantData

use rowCount property, expanded JSON always return this when the query return empty dataset.


Esteban

Offline

#5 2018-03-07 15:43:49

mauriciobs
Member
From: Brazil
Registered: 2016-05-11
Posts: 16

Re: RetrieveListJSON and TDocVariantData

Try this.

MyGrid.DataSource.DataSet := JSONToDataSet(self, MyModelHttpClient.RetrieveListJSON(TSQLMyRecord,'',''));

Offline

#6 2018-03-07 16:54:08

triguinhu
Member
From: Brazil
Registered: 2016-07-28
Posts: 27

Re: RetrieveListJSON and TDocVariantData

EMartin


How do I get access to this property?


Mauricio


Yes, using JSONToDataset works, but this method uses the unit MormotVCL and I migrated the example to an FMX client, and the JSONtoDataset method does not work with FMX so I am trying to use the ToDataset method and directly manipulate the return in DocVariantData. If there is any other alternative for FMX clients I'm happy to find out

Offline

#7 2018-03-07 20:47:12

EMartin
Member
From: Buenos Aires - Argentina
Registered: 2013-01-09
Posts: 337

Re: RetrieveListJSON and TDocVariantData

EMartin


How do I get access to this property?

you are see a DocVariantData and can access to property in this way:

DocVariantData(variantdoc).value['rowCount']

Esteban

Offline

Board footer

Powered by FluxBB