Virtualtable and empty string-fields

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
tonisanta
Posts: 55
Joined: Wed 04 Apr 2007 17:25

Virtualtable and empty string-fields

Post by tonisanta » Thu 16 Apr 2009 13:17

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

shreq
Posts: 8
Joined: Fri 20 Mar 2009 11:26

Re: Virtualtable and empty string-fields

Post by shreq » Fri 17 Apr 2009 06:31

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 ''
)

tonisanta
Posts: 55
Joined: Wed 04 Apr 2007 17:25

Post by tonisanta » Fri 17 Apr 2009 06:48

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.

Dimon
Devart Team
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 17 Apr 2009 12:08

In order to solve this problem please use the SaveToXML method instead of SaveToFile.

tonisanta
Posts: 55
Joined: Wed 04 Apr 2007 17:25

Post by tonisanta » Mon 20 Apr 2009 09:08

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

Dimon
Devart Team
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 21 Apr 2009 14:24

We don't plan to implement such fix, because this is very specific functionality and it is not always correct for different servers.

tonisanta
Posts: 55
Joined: Wed 04 Apr 2007 17:25

Post by tonisanta » Tue 21 Apr 2009 14:35

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

Dimon
Devart Team
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 22 Apr 2009 07:17

Ok. We will investigate the possibility of adding this functionality in the near future.

Dimon
Devart Team
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 12 Jun 2009 12:41

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.

Post Reply