Preserve persistent fields when loading from stream

Preserve persistent fields when loading from stream

Postby jim papas » Sat 28 Feb 2015 13:17

I try to use VirtualTable (v9.4.8 for XE7) in my app.
I have a table with many lookup and calculated fields among other data fields.
When i load the table from a previous saved stream/file, the persistent fields become nil, so i can refer them only using "fieldByName".
But the most important is that i have to recreate the lookup and calculated fields every time i load the table and this happens hundred times (slave tables of a master table).
I saw this announcement "15-Jun-11 New Features in VirtualTable 7.20
•Possibility to load data without recreating persistent fields is added[/i]"
This means that THERE IS a way to preserve them.
What can i do to do this, please ?
jim papas
 
Posts: 7
Joined: Sat 28 Feb 2015 12:53

Re: Preserve persistent fields when loading from stream

Postby AlexP » Mon 02 Mar 2015 12:00

Hello,

To solve the problem, you should set False as the second parameter on the LoadFromStream/LoadFromFile method

Code: Select all
VirtualTable1.LoadFromStream(MemorySream, False);
AlexP
Devart Team
 
Posts: 5528
Joined: Tue 10 Aug 2010 11:35

Re: Preserve persistent fields when loading from stream

Postby jim papas » Mon 02 Mar 2015 15:08

Thanks, this solved my problem. Shame to me that i didn't saw that it has second parameter !
But now another problem raised up.
Some persistent boolean fields have defaultExpresion AND displayValues.
Loading from stream i receive the error "FALSE is not a valid boolean value for field xxx"
It seems that defaultExpresion and displayValues prevents one the other. They can't excist together.
Is this the case ?
jim papas
 
Posts: 7
Joined: Sat 28 Feb 2015 12:53

Re: Preserve persistent fields when loading from stream

Postby AlexP » Tue 03 Mar 2015 09:44

This occurs due to incorrect setting of DisplayValues for Boolean fields. For such fields, DisplayValues must be set in the following way:

Code: Select all
BooleanField.SetDisplayValues := 'TRUE;FALSE';


Where the first value is True, and the second one is False. These values are saved in the FTextValues array in the TBooleanField.SetDisplayValues method.
AlexP
Devart Team
 
Posts: 5528
Joined: Tue 10 Aug 2010 11:35

Re: Preserve persistent fields when loading from stream

Postby jim papas » Tue 03 Mar 2015 10:29

Yes, i found that it saves boolean fields as text not as byte.
So i must set as default value one of the displayValues eg
defaultValue : aaa
displayValues: aaa;bbb

But... another issue arrived.
The autoinc field doesn't get value by itself. It works like an integerField. I can set any value in it.
I tried setting the autoGenerateValue to arAutoInc without success
jim papas
 
Posts: 7
Joined: Sat 28 Feb 2015 12:53

Re: Preserve persistent fields when loading from stream

Postby AlexP » Tue 03 Mar 2015 12:44

The ftAutoInc field type means, that data in this field will be generated automatically at the level of the database (depending on the algorithm of retrieving auto-incremental values). There is no sense to use this field type in VirtualTable.
AlexP
Devart Team
 
Posts: 5528
Joined: Tue 10 Aug 2010 11:35

Re: Preserve persistent fields when loading from stream

Postby jim papas » Tue 03 Mar 2015 13:20

ok, i can live without it.
But, i think that should be supported, as other memTables do, since it is there.

As far as i see, your component is better than others. Thanks
jim papas
 
Posts: 7
Joined: Sat 28 Feb 2015 12:53

Re: Preserve persistent fields when loading from stream

Postby AlexP » Tue 03 Mar 2015 14:17

You can leave your suggestion on our uservoice page. If it gets enough user votes, we will implement it.
Currently, to implement behavior similar to auto-incrementation, you can use events, for example, BeforeInsert and AfterPost to fill in the required field with the needed values.
AlexP
Devart Team
 
Posts: 5528
Joined: Tue 10 Aug 2010 11:35


Return to VirtualDAC