Page 1 of 1

Virtualtable and empty string-fields

Posted: Thu 16 Apr 2009 13:17
by tonisanta
Hi, I use VirtualTables to export from and import into SQL-Tables. Now I've the problem that after importing empty stringfields (value = '') are no longer empty but . Is there any option to avoid this?
To reproduce create a VirtualTable, add 2 string-fields, add a record with one field set to null and the second to an empty string, save it to file, reload it from file and check the contents of the fields: both are set do null.
best regards
Toni Santa

Re: Virtualtable and empty string-fields

Posted: Fri 17 Apr 2009 06:31
by shreq
tonisanta wrote:Hi, I use VirtualTables to export from and import into SQL-Tables. Now I've the problem that after importing empty stringfields (value = '') are no longer empty but . Is there any option to avoid this?
To reproduce create a VirtualTable, add 2 string-fields, add a record with one field set to null and the second to an empty string, save it to file, reload it from file and check the contents of the fields: both are set do null.
best regards
Toni Santa
Maybe you need change a little table field definitions:

CREATE TABLE MyTable (
stringfield varchar(100) NOT NULL DEFAULT ''
)

Posted: Fri 17 Apr 2009 06:48
by tonisanta
In my particular case this is not applicable since the field sometimes should contain and in other cases an empty string. I was lining out a problem of the SaveTo- and LoadFrom-procedures of the VirtualTable, which - so my meaning - should be solved by DevArt.

Posted: Fri 17 Apr 2009 12:08
by Dimon
In order to solve this problem please use the SaveToXML method instead of SaveToFile.

Posted: Mon 20 Apr 2009 09:08
by tonisanta
Hi, with SaveToXML the "NULL - EMTPY STRING" - problem seems to be gone, but DateTime-fields with large precision (milliseconds) are truncated. But this is not a huge problem. The generated XML-Files are approximately 30% larger as "saveToFile"-files. Will there be a fix in future releases to export/import empty strings as such without "converting" them to NULL?
best regards, Toni

Posted: Tue 21 Apr 2009 14:24
by Dimon
We don't plan to implement such fix, because this is very specific functionality and it is not always correct for different servers.

Posted: Tue 21 Apr 2009 14:35
by tonisanta
Your are the developers and therefore the decision is yours. From my point of view nulls and empty strings are not the same and so a sequence of SaveToFile and LoadFromFile should retain the original values of the fields. For currencyfields this seems to work fine, null remains null and 0 remains 0. Could be you provide an optional parameter 'ConvertEmptyStringsToNull' when saving to/loading from file?
with regards, Toni

Posted: Wed 22 Apr 2009 07:17
by Dimon
Ok. We will investigate the possibility of adding this functionality in the near future.

Posted: Fri 12 Jun 2009 12:41
by Dimon
To new build of SDAC version 4.70.0.47 was added distinction between empty string and null value when saving/loading string fields in TVirtualTable.