Trapping exception to dynamically code a work around

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
sandy771
Posts: 194
Joined: Tue 22 May 2007 13:57

Trapping exception to dynamically code a work around

Post by sandy771 » Tue 02 Sep 2014 22:45

I have an application that supports multiple SQLite databases the schema of which is outside of my control.

One of the databases has fields with a definition similar to

create table test (f1 varchar, f2 timestamp)

however that data written to f2 is a float (sqlite allows this) and when I run a simple select query I get an ecception "29222606067.14 julian cannot be represented as a datetime"

How can I trap this situation and deal with it?

sandy771
Posts: 194
Joined: Tue 22 May 2007 13:57

Re: Trapping exception to dynamically code a work around

Post by sandy771 » Wed 03 Sep 2014 09:30

Further to this

I have data typeing mapping to map between a datetime and a float (or vice versa) - but the same error occurs.

I see that something similar has come up before and I notice in the release notes for version 5 it says
Converter from Unix and Julian data formats to ftDateTime is added
If this is fixed, how do I implement it on a field by field basis?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Trapping exception to dynamically code a work around

Post by AlexP » Thu 04 Sep 2014 12:32

Hello,

To get such date as Float, you should set the NativeDate option to False and use the AsFloat method for the field. If you want to display such float values in the grid, you can use the onGetText event of this field, retrieve the value using the AsFloat method, map it explicitly to string or to date by modifying it as required.

Post Reply