Discussion:
Convert field type
(too old to reply)
miromr
2008-04-08 14:15:27 UTC
Permalink
If we want to speak about Delphi aplications as database independent and
transferable from one database system to another, there must be an easy way
of remaping field from one type to another, e.g.







TDateTime to TSqlTimeStamp

TFMTBCD to Integer

etc.





Unfortunately, in the course of our work, we encountered the problem, that
our application, that Works without problems on Interbase, Firebird, MS SQL
and Sybase databases, does not work on Oracle database. The problem is as

follows:

I am not familiar with any easy way how to reach field remaping without
significant changes in source code.



Can you advise us some easy way of remaping, or/and send us a part of a
sample code?



Thank you

Miro
miromr
2008-04-08 14:17:33 UTC
Permalink
If we want to speak about Delphi aplications as database independent and
transferable from one database system to another, there must be an easy way
of remaping field from one type to another, e.g.
TDateTime to TSqlTimeStamp
TFMTBCD to Integer
etc.
Unfortunately, in the course of our work, we encountered the problem, that
our application, that Works without problems on Interbase, Firebird, MS SQL
and Sybase databases, does not work on Oracle database. The problem is as
follows:
I am not familiar with any easy way how to reach field remaping without
significant changes in source code.
Can you advise us some easy way of remaping, or/and send us a part of a
sample code?
Thank you

Miro
albert drent
2008-04-08 16:38:54 UTC
Permalink
Post by miromr
If we want to speak about Delphi aplications as database independent and
transferable from one database system to another, there must be an easy way
of remaping field from one type to another, e.g.
TDateTime to TSqlTimeStamp
TFMTBCD to Integer
etc.
Unfortunately, in the course of our work, we encountered the problem, that
our application, that Works without problems on Interbase, Firebird, MS SQL
and Sybase databases, does not work on Oracle database. The problem is as
I am not familiar with any easy way how to reach field remaping without
significant changes in source code.
Can you advise us some easy way of remaping, or/and send us a part of a
sample code?
Thank you
Miro
Database independency is not completely possible if you don't stay with
the ansi standard. There are several ways of creating inner/outer joins
(i.e. + with Oracle) which is not compatible between db's. Same goes for
datatypes. Within Delphi this isue is solved by using .AsSomething, but
if this is not suitable then conversions needs to be made yourself. I
could think of software solutions, something similar to xml mapper but
it would still be a lot of work I guess.
TProgrammer
2008-04-08 20:14:19 UTC
Permalink
You are right, remapping fields to another datatype cannot be achieved
easily.

The secret for cross-database apps is: runtime for everything.
Don't hardcode sql statements, and more importantly don't rely on persistent
fields.
Post by miromr
If we want to speak about Delphi aplications as database independent and
transferable from one database system to another, there must be an easy
way of remaping field from one type to another, e.g.
TDateTime to TSqlTimeStamp
TFMTBCD to Integer
etc.
Unfortunately, in the course of our work, we encountered the problem, that
our application, that Works without problems on Interbase, Firebird, MS
SQL and Sybase databases, does not work on Oracle database. The problem is
as
I am not familiar with any easy way how to reach field remaping without
significant changes in source code.
Can you advise us some easy way of remaping, or/and send us a part of a
sample code?
Thank you
Miro
Jan Doggen
2008-04-11 18:46:59 UTC
Permalink
My $0.02

I wrote a large data transfer app years ago and here are my experiences with
things being *not* so straightforward. The app transfered data between
DBMSes.
- there is always a mapping from the DBMS datatypes to Delphi's field types,
this generally works well for the simpler types, but as soon as you dive
into timestamps, datetime etc things become sometimes more difficult,
especially because the naming of DBMS field type is not consistent (a 'date'
type actually being a datetime etc).
- in their respective DBMSs field with the same Delphi fieldtype may have
different maximum values
- they can also have different precisions, meaning that Delphi will map it
to either a tBCD or a tFmtBCD
- then there's always nitty gritty details of trying to read a valid 24:00
time in DB2 ;-)

The only way we could handle this properly was really *knowing* all the
field types and writing conversion tables in our technical design, so that
we could handle the type mismatches/conversions.
In the app I even added persistent fields at runtime to handle some
inconsistencies.

This is not to frighten you away, but be prepared to handle what comes up
;-)

Bye
JAn
Post by miromr
If we want to speak about Delphi aplications as database independent and
transferable from one database system to another, there must be an easy
way of remaping field from one type to another, e.g.
TDateTime to TSqlTimeStamp
TFMTBCD to Integer
etc.
Unfortunately, in the course of our work, we encountered the problem, that
our application, that Works without problems on Interbase, Firebird, MS
SQL and Sybase databases, does not work on Oracle database. The problem is
as
I am not familiar with any easy way how to reach field remaping without
significant changes in source code.
Can you advise us some easy way of remaping, or/and send us a part of a
sample code?
Thank you
Miro
Loading...