Subject | Re: Tib_Import doesn't fail/throw exception when data type is incorrect ? |
---|---|
Author | sshowl09 |
Post date | 2009-08-25T11:03:57Z |
Hi,
Any assistance with this issue/suggestions is appreciated, I am working to a deadline and need to get this problem solved.
If the first row in the csv file contains an invalid date then that date will end up in the database table date column as null, eg :
1,sdfsdf,ELLEN,HUNTER,February
2,07/26/2007,RACHEL,BREWER,March
3,12/21/2007,ELSIE,MEDINA,July
4,01/02/2009,JESSICA,DOUGLAS,January
Row 1 is inserted with a null date.
If the invalid date is not on the first row it will be given the date value of the preceeding row eg :
1,12/21/2007,ELLEN,HUNTER,February
2,sdsd,RACHEL,BREWER,March
3,12/21/2007,ELSIE,MEDINA,July
4,01/02/2009,JESSICA,DOUGLAS,January
Row 2 is inserted with a date value of 12/21/2007, it has inherited that date value from row 1!
What I would like to happen is for the TIB_Import to throw an exception or report an error if a value in the csv going into a date
column is not a valid date.
I have taken a look at IB_Import.pas and think the relevant area is
around line 1203 :
DSql.Params[p].AsString := AsciiFields[ii];
I can hack around in there and try and add some type checking (in my case I only need it for dates), but i wonder if there is already a mechanism available.
Cheers
Samh
Any assistance with this issue/suggestions is appreciated, I am working to a deadline and need to get this problem solved.
If the first row in the csv file contains an invalid date then that date will end up in the database table date column as null, eg :
1,sdfsdf,ELLEN,HUNTER,February
2,07/26/2007,RACHEL,BREWER,March
3,12/21/2007,ELSIE,MEDINA,July
4,01/02/2009,JESSICA,DOUGLAS,January
Row 1 is inserted with a null date.
If the invalid date is not on the first row it will be given the date value of the preceeding row eg :
1,12/21/2007,ELLEN,HUNTER,February
2,sdsd,RACHEL,BREWER,March
3,12/21/2007,ELSIE,MEDINA,July
4,01/02/2009,JESSICA,DOUGLAS,January
Row 2 is inserted with a date value of 12/21/2007, it has inherited that date value from row 1!
What I would like to happen is for the TIB_Import to throw an exception or report an error if a value in the csv going into a date
column is not a valid date.
I have taken a look at IB_Import.pas and think the relevant area is
around line 1203 :
DSql.Params[p].AsString := AsciiFields[ii];
I can hack around in there and try and add some type checking (in my case I only need it for dates), but i wonder if there is already a mechanism available.
Cheers
Samh
--- In IBObjects@yahoogroups.com, "sshowl09" <sshowl09@...> wrote:
>
> Hi,
>
> I'm using TIB_Import to import from a CSV file to a table.
>
> One of the columns in the table is a date, interestingly if the CSV file contains values for that column that are no dates, are random strings for example, the import doesn't fail, it simply repeats the last valid value for that column.
>
> Is there a way to make it so it does fail if data does not match the destination column ?
>
> In CSV (note 3rd row has string in place of date):
>
> 1,12/21/2007,ELLEN,HUNTER,February
> 2,07/26/2007,RACHEL,BREWER,March
> 3,fgg,ELSIE,MEDINA,July
> 4,01/02/2009,JESSICA,DOUGLAS,January
>
> Ends up in database table (3rd row has inherited date of second),
> the 2nd col is indeed a date type in the table):
>
> 1,12/21/2007,ELLEN,HUNTER,February
> 2,07/26/2007,RACHEL,BREWER,March
> 3,07/26/2007,ELSIE,MEDINA,July
> 4,01/02/2009,JESSICA,DOUGLAS,January
>
> Help appreciated.
>
> Cheers
> Sam
>