Mega Search
23.2 Million


Sign Up

Make a donation  
FDBatchMove mapping error  
News Group: embarcadero.public.delphi.database.firedac

Using Delphi XE7 update 1 for an Android app with FireDAC and SQLite
tables.

I am trying to import/load records from CSV files.
An example line from the most basic CSV file I have to use is:  
	1000|1000|1|105|A|1
Note that the separator is '|' and that text field data is not
delimited.

The file rows exactly match the Table structure, ie in this example: 
	Integer|Integer|Integer|Integer|String|Integer

I have tried setting the FDBatchMove Reader's Separator to '|' and the
Delimiter to #0 (and also tried some other values such as ") but I
always get the error:
	[FireDAC][Comp][DM]-607. Bad text value [1000] format for mapping item
[MRef->MRef]. '1000' is not a valid integer value.
(MRef is the first field name).

OK, '1000' is a string.  So I tried defining the field types in the
Reader's DataDef.Fields collection but that did not help.  I tried
several other things but the only one that worked was to change the
Table fields to text which would be OK for some of my tables, but not
all.

Can I use FDBatchMove with CSV files such as the above?  Am I simply
missing the obvious?  Or must I load the data in some other way?

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 12-Jan-2015, at 9:46 AM EST
From: Malcolm Taylor
 
Re: FDBatchMove mapping error  
News Group: embarcadero.public.delphi.database.firedac
Hi Dmitry

Here is a small example showing the problem (at my end).

CREATE TABLE IF NOT EXISTS events (
MRef STRING,
ERef INTEGER PRIMARY KEY ASC NOT NULL,
ETitle STRING,
EDate STRING,
ESex STRING,
Cat1 STRING,
Cat2 STRING,
Cat3 STRING,
Cat4 STRING,
Cat5 STRING,
Cat6 STRING,
Synchro BOOLEAN DEFAULT 'False',
MinAge INTEGER DEFAULT 0,
MaxAge INTEGER DEFAULT 0,
MaxDD FLOAT DEFAULT 0.0,
Board STRING
)

A matching CSV file contains:

1000|1000|Mens 1m|2015-12-31|M|||||||False|0|0|0.0|1
1000|1001|Mens 3m|2015-12-31|M|||||||False|0|0|0.0|3
1000|1002|Mens Platform|2015-12-31|M|||||||False|0|0|0.0|H
1000|1003|Mens 3m Synchro|2015-12-31|M|||||||True|0|0|0.0|3
1000|1004|Mens Platform Synchro|2015-12-31|M|||||||True|0|0|0.0|H
1000|1005|Womens 1m|2015-12-31|F|||||||False|0|0|0.0|1
1000|1006|Womens 3m|2015-12-31|F|||||||False|0|0|0.0|3
1000|1007|Womens Platform|2015-12-31|F|||||||False|0|0|0.0|H
1000|1008|Womens 3m Synchro|2015-12-31|F|||||||True|0|0|0.0|3
1000|1009|Womens Platform Synchro|2015-12-31|F|||||||True|0|0|0.0|H

With MRef defined as STRING the FDBatchMove works fine (Separator '|'
and Delimeter #0).
But with MRef defined as INTEGER it fails with the data match error.
It is as if there was some non-printing character at the start of the
file or line.  But there should not be any BOM.
Being on Android the encoding will be ecUTF8.

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 13-Jan-2015, at 1:18 PM EST
From: Malcolm Taylor
 
Re: FDBatchMove mapping error  
News Group: embarcadero.public.delphi.database.firedac
Could you please post a sample CSV file to attachments newsgroup ?

-- 
With best regards,
Dmitry Arefiev / FireDAC Architect

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 13-Jan-2015, at 10:14 AM EST
From: Dmitry Arefiev
 
Re: FDBatchMove mapping error  
News Group: embarcadero.public.delphi.database.firedac
I have now determined that it is only the first CSV field that is being
interpreted as a string.
All the other ones have their types correctly mapped to the Table
fields.

I even tried changing the field name in case I had some conflict
elsewhere.

So what do I have to do to get the first value interpreted as an
integer?

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 12-Jan-2015, at 12:27 PM EST
From: Malcolm Taylor