Preserve persistent fields when loading from stream
Preserve persistent fields when loading from stream
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 ?
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 ?
Re: Preserve persistent fields when loading from stream
Hello,
To solve the problem, you should set False as the second parameter on the LoadFromStream/LoadFromFile method
To solve the problem, you should set False as the second parameter on the LoadFromStream/LoadFromFile method
Code: Select all
VirtualTable1.LoadFromStream(MemorySream, False);
Re: Preserve persistent fields when loading from stream
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 ?
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 ?
Re: Preserve persistent fields when loading from stream
This occurs due to incorrect setting of DisplayValues for Boolean fields. For such fields, DisplayValues must be set in the following way:
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.
Code: Select all
BooleanField.SetDisplayValues := 'TRUE;FALSE';
Re: Preserve persistent fields when loading from stream
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
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
Re: Preserve persistent fields when loading from stream
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.
Re: Preserve persistent fields when loading from stream
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
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
Re: Preserve persistent fields when loading from stream
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.
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.